From a8b754a1cc991b7e4e5437c4fe37ea22b639ad2f Mon Sep 17 00:00:00 2001 From: Daniel Bosk Date: Thu, 13 Jun 2024 14:20:27 +0200 Subject: [PATCH] Adds -i/--id option to courses command --- src/canvaslms/cli/courses.nw | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/canvaslms/cli/courses.nw b/src/canvaslms/cli/courses.nw index ec93dff..8dd486e 100644 --- a/src/canvaslms/cli/courses.nw +++ b/src/canvaslms/cli/courses.nw @@ -21,7 +21,7 @@ def add_command(subp): courses_parser = subp.add_parser("courses", help="Lists your courses", description="Lists your courses. Output, CSV-format: " - " ") + "<>") courses_parser.set_defaults(func=courses_command) <> @ @@ -82,13 +82,26 @@ if not args.all: We have the course data in a [[course]] object. Now we just print the interesting data about it. +<>= +* <>= -output.writerow([ +row = [] +if args.id: + row.append(course.id) +row.extend([ course.course_code, course.name, course.start_at, course.end_at ]) +output.writerow(row) +@ + +We add the option [[--id]] to show the Canvas ID of the course. +<>= +courses_parser.add_argument("-i", "--id", + action="store_true", default=False, + help="Include Canvas ID of the course as first column.") @