ap
CLI tool that builds the exact folder and zip structure Canvas wants for C assignment submissions.
Install
Cargo (any platform)
Homebrew (macOS/Linux)
Scoop (Windows)
scoop bucket add ap https://github.com/cat-forgor/AssignmentPacker
scoop install ap
Chocolatey (Windows)
choco install ap
WinGet (Windows)
winget install cat-forgor.ap
Nix (NixOS / any platform)
AUR (Arch Linux)
Debian/Ubuntu (.deb)
Grab the .deb from releases:
Windows Installer (.msi)
Download ap-windows-x64.msi from releases and run it. It installs to Program Files and adds ap to your PATH automatically.
Pre-built binaries
Head to releases and grab the latest binary.
Windows: rename it to ap.exe and add it to your PATH.
Linux/macOS:
From source
Requires Rust 1.85+ (edition 2024):
Quick start
Two commands and you're good to go:
Once you've run ap init, you'll rarely need to type anything more than ap -a 7.
Usage
# full command with auto-doc
# bring your own doc instead
# minimal (once you've run ap init)
# pipe stdin input non-interactively
# custom timeout in seconds (clamped to 5 to 300)
Flags
| Flag | Short | Description |
|---|---|---|
--assignment |
-a |
Assignment number or label (e.g. 7 or Assignment7) |
--name |
-n |
Student name |
--id |
-i |
Student ID |
--c-file |
-c |
Path to .c file (auto-detected if only one exists in cwd) |
--doc-file |
-d |
Path to an existing .doc file |
--auto-doc |
Generate a .doc automatically |
|
--run-command |
Custom shell command to compile and run your program | |
--input |
Pipe stdin input (supports \n, \r, \0, \xNN escapes) |
|
--timeout |
Run timeout in seconds (default 30, clamped to 5 to 300) | |
--run-display-template |
Customize what the terminal prompt shows in the screenshot | |
--theme |
-t |
Screenshot theme (default, light, dracula, monokai, solarized) |
--output-dir |
-o |
Output directory (defaults to .) |
--no-watermark |
Turns off the watermark at the bottom of the doc | |
--force |
-f |
Overwrite existing output |
Config
Setting defaults
Save any CLI flag as a default using ap config set:
Need to clear a saved value? Use the --clear-* variants:
CLI flags always override config values. The config itself is plain TOML and lives at ~/.config/assignment_packer/config.toml on Linux/macOS or %APPDATA%\assignment_packer\config.toml on Windows.
You can set a preferred editor with --editor. If you don't, ap checks $VISUAL and $EDITOR first then looks for common editors in your PATH.
Auto-doc
Turn on --auto-doc and ap takes care of everything for you:
- Finds
gccorclangand compiles your.cfile - Runs the binary and captures stdout/stderr
- Renders a terminal screenshot as a PNG
- Packages your code, the screenshot, and the captured output into a
.doc
Custom run command
By default ap compiles with gcc/clang and runs the result. Need something different? Just override it:
# custom compile + run
# run a pre-built binary
Save it to config so you don't have to type it every time:
Programs that need input
If your program reads from stdin, you've got two options:
# 1) input directly
# 2) interactive terminal input (default when --input isn't set)
Interactive mode prints a hint while your program runs:
Program is running. If it doesn't exit on its own, press Ctrl+Z/Ctrl+D.
Display template
The screenshot shows a $ command prompt line. By default it uses the assignment name like $ Assignment7. Use --run-display-template to change it:
# expands to something like: ./home/cat/assignments/19/main
Available placeholders:
| Placeholder | Example value |
|---|---|
{assignment} |
Assignment7 |
{assignment_number} |
7 |
{name} |
JoeBloggs |
{id} |
123456789 |
{c_file} |
main.c |
{c_stem} |
main |
Save it to config like anything else:
Themes
Five built-in themes control how the terminal screenshot looks in your doc:
default light dracula monokai solarized
Want a custom theme? Drop a TOML file into ~/.config/assignment_packer/themes/:
# ~/.config/assignment_packer/themes/nord.toml
= "#2E3440"
= "#D8DEE9"
= 2 # 1 to 4
= 16 # max 64
= "JetBrainsMono-Regular.ttf" # relative to themes dir, or absolute path
= 16 # pixel height (8 to 72)
Then use it with --theme nord. Subdirectories work fine too:
~/.config/assignment_packer/themes/
nord.toml
dark/
dracula.toml
monokai.toml
Screenshots are capped at 8192×8192 pixels.
Updates
Check if a newer release is out:
Output structure
Running ap -a 7 -n JoeBloggs -i 123456789 produces:
Assignment7_JoeBloggs_123456789_Submission/
Assignment7_JoeBloggs_123456789.doc # if --auto-doc or --doc-file was used
main.c # your source file
... (all non-binary files in cwd)
Assignment7_JoeBloggs_123456789_Submission.zip
Upload the zip to Canvas and you're done.