A barebones CLI tool that keeps local folders up-to-date with online folders on Canvas.
Make a canvas.json
file and save it somewhere in your system.
JSON
{
"token": "",
"base_path": "~/files/canvas-api",
"maps": [
{
"url": "https://canvas.nus.edu.sg/courses/36736/files/folder/Tutorials",
"path": "MA2104/tut"
},
{
"url": "https://canvas.nus.edu.sg/courses/36741/files/folder/Lecture%20Notes",
"path": "MA2108/lec"
},
]
}
There are three key components in your config:
token
- this is what authenticates into canvas instead of a
username and password. This can be found at your canvas profile
settings and looking
around for the 'token' keyword. Generate a fresh one and make sure
to save the token string to a safe location.
base_path
- this is an optional parameter that will pre-pend all
other paths in your config. Leave this out of your config if you
want greater freedom in specifying each path. Otherwise, it's a
nice way to shorten all your other paths.
maps
- this is an array of { url, path }
objects. url
points
to the folder on canvas that you want to track. path
points to
the local directory on your computer that you want to be synced
with that folder online.
Once you have specified your configuration, to make your local folders update to date with canvas, execute the command
sh
canvas-sync /path/to/canvas.json