lms .cli .courses .list
List courses.
usage: python3 -m lms.cli.courses.list [-h] [--version] [--server SERVER]
[--server-type {blackboard,canvas,moodle}]
[--auth-user AUTH_USER]
[--auth-password AUTH_PASSWORD]
[--auth-token AUTH_TOKEN]
[--format {json,table,text}]
[--include-extra-fields]
[--pretty-headers] [--skip-headers]
List courses.
options:
-h, --help show this help message and exit
--version show program's version number and exit
server options:
--server SERVER The address of the LMS server to connect to.
--server-type {blackboard,canvas,moodle}
The type of LMS being connected to (this can normally
be guessed from the server address).
authentication options:
--auth-user AUTH_USER
The user to authenticate with.
--auth-password AUTH_PASSWORD
The password to authenticate with.
--auth-token AUTH_TOKEN
The token to authenticate with.
output formatting options:
--format {json,table,text}
The format to display the output as (default: text).
--include-extra-fields
Include non-common (usually LMS-specific) fields in
results (default: False).
--pretty-headers When displaying headers, try to make them look
"pretty" (default: False).
--skip-headers Skip headers when outputting results, will not apply
to all formats (default: False).
1""" 2List courses. 3""" 4 5import argparse 6import sys 7 8import lms.backend.instance 9import lms.cli.parser 10import lms.model.base 11 12def run_cli(args: argparse.Namespace) -> int: 13 """ Run the CLI. """ 14 15 config = args._config 16 17 backend = lms.backend.instance.get_backend(**config) 18 courses = backend.courses_list() 19 20 output = lms.model.base.base_list_to_output_format(courses, args.output_format, 21 skip_headers = args.skip_headers, 22 pretty_headers = args.pretty_headers, 23 include_extra_fields = args.include_extra_fields, 24 ) 25 26 print(output) 27 28 return 0 29 30def main() -> int: 31 """ Get a parser, parse the args, and call run. """ 32 return run_cli(_get_parser().parse_args()) 33 34def _get_parser() -> argparse.ArgumentParser: 35 """ Get the parser. """ 36 37 return lms.cli.parser.get_parser(__doc__.strip(), 38 include_output_format = True, 39 ) 40 41if (__name__ == '__main__'): 42 sys.exit(main())
def
run_cli(args: argparse.Namespace) -> int:
13def run_cli(args: argparse.Namespace) -> int: 14 """ Run the CLI. """ 15 16 config = args._config 17 18 backend = lms.backend.instance.get_backend(**config) 19 courses = backend.courses_list() 20 21 output = lms.model.base.base_list_to_output_format(courses, args.output_format, 22 skip_headers = args.skip_headers, 23 pretty_headers = args.pretty_headers, 24 include_extra_fields = args.include_extra_fields, 25 ) 26 27 print(output) 28 29 return 0
Run the CLI.
def
main() -> int:
31def main() -> int: 32 """ Get a parser, parse the args, and call run. """ 33 return run_cli(_get_parser().parse_args())
Get a parser, parse the args, and call run.