Skip to content

Commit

Permalink
Merge pull request #160 from dbosk/add-canvas-id-to-courses-output
Browse files Browse the repository at this point in the history
Adds -i/--id option to courses command
  • Loading branch information
dbosk authored Jun 13, 2024
2 parents 935125f + a8b754a commit b0350f3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/canvaslms/cli/courses.nw
Original file line number Diff line number Diff line change
Expand Up @@ -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: "
"<course-code> <course-name> <start-time> <end-time>")
"<<columns in CSV output>>")
courses_parser.set_defaults(func=courses_command)
<<add arguments>>
@
Expand Down Expand Up @@ -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.
<<columns in CSV output>>=
<canvas ID>* <course-code> <course-name> <start-time> <end-time>
<<write course data to output>>=
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.
<<add arguments>>=
courses_parser.add_argument("-i", "--id",
action="store_true", default=False,
help="Include Canvas ID of the course as first column.")
@


Expand Down

0 comments on commit b0350f3

Please sign in to comment.