Command-line interface for Campus API
git clone https://github.com/nyjc-computing/campus-cli.git
cd campus-cli
pip install .This installs the campus command system-wide.
# Authenticate with Campus API
campus auth login
# Create an OAuth client
campus client new --name "My App" --description "My application"
# Generate the client's secret (only time it is shown)
campus client revoke --client-id <id>
# List vault entries
campus vault list --vault myvault
# Preview any command as equivalent Python code (no API call made)
campus client new --name "My App" --description "My application" --dry-runAll client and vault commands accept --dry-run. Instead of
authenticating and calling the API, the command prints the equivalent
Python snippet using the
campus-api-python
library — useful for learning how to call the Campus API from Python:
from campus_python import Campus
campus = Campus(timeout=30, mode="device")
campus.auth.client.set_bearer_authorization("<access_token>")
client = campus.auth.clients.new(
name='My App',
description='My application',
)
print(client.id)Destructive commands — auth logout, client delete, client revoke,
vault delete — confirm before acting. When no terminal is attached
the CLI never blocks waiting for input: it refuses immediately with an
error naming the remedy. Waive the confirmation per command with
--confirm/-y, or for a whole session with the CAMPUS_ASSUME_YES
environment variable (1/true/yes):
campus client delete --client-id <id> -y # per command
CAMPUS_ASSUME_YES=1 campus auth logout # per sessionAutomation should expect exit code 1 and a Refusing to proceed
message on stderr when a destructive command is invoked without a
waiver.
For development and testing, use Poetry to install the project with development dependencies:
poetry install
poetry run pytestRun the CLI using poetry run:
poetry run campus --helpIf you use poetry shell to activate the virtual environment and encounter ModuleNotFoundError: No module named 'main', exit the shell and rebuild:
exit
rm -f .venv/Scripts/campus.exe .venv/Scripts/campus
poetry build && poetry install
poetry shellIf you don't have Poetry installed:
pip install poetry- Development Guide - Testing, hooks, and development workflow
- Product Requirements - Product requirements document
- Implementation Plan - Implementation details