Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds -i/--id option to courses command #160

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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