Skip to content

Repository files navigation

campus-cli

Command-line interface for Campus API

Installation

git clone https://github.com/nyjc-computing/campus-cli.git
cd campus-cli
pip install .

This installs the campus command system-wide.

Usage

# 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-run

Dry-run mode

All 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)

Non-interactive use (scripts, CI, agents)

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 session

Automation should expect exit code 1 and a Refusing to proceed message on stderr when a destructive command is invoked without a waiver.

Development

For development and testing, use Poetry to install the project with development dependencies:

poetry install
poetry run pytest

Run the CLI using poetry run:

poetry run campus --help

If 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 shell

If you don't have Poetry installed:

pip install poetry

Documentation

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages