Last Updated: 2025-03-11
- ✅ Phase 1: Core Infrastructure (CLI entry point, credentials, config, output formatting)
- ✅ Phase 2: Authentication (OAuth device flow, logout, token storage, auto-refresh)
- ✅ Phase 3: OAuth Client Commands (list, new, get, update, delete, revoke)
- ✅ Phase 4: Client Access Commands (get, grant, revoke, update)
- ✅ Phase 5: Vault Commands (list, get, set, delete)
- ⏳ Phase 6: Polish & Packaging
- ⏳ API Resource Commands (timetable, assignments, circles, users)
- ⏳ Testing
campus-cli/
├── campus_cli/
│ ├── __init__.py
│ ├── api.py # Campus API client wrapper
│ ├── cli.py # Main CLI entry point
│ ├── config.py # Configuration management
│ ├── credentials.py # Credential storage abstraction
│ ├── auth/
│ │ ├── __init__.py
│ │ ├── common.py # Shared utilities (token refresh, API client)
│ │ ├── login.py # OAuth login flow (login, logout, refresh, status)
│ │ ├── client.py # Client management commands
│ │ └── vault.py # Vault commands
│ └── utils/
│ ├── __init__.py
│ └── output.py # Formatted output (table/json)
├── tests/
├── docs/
├── .devcontainer/
├── pyproject.toml
└── README.md
- Language: Python 3.11+
- CLI Framework: Typer (modern, type-annotated CLI built on Click)
- Output Formatting: Rich for beautiful terminal output
- Credential Storage: keyring library with platform backends
- API Client: campus-api-python
- ✅ Create main CLI entry point with Typer
- ✅ Set up credential storage abstraction using keyring
- ✅ Create configuration management (auth_url, auto_refresh, refresh_threshold)
- ✅ Set up output formatting utilities (Rich)
- ✅ Implement OAuth device authorization flow
- Request device code
- Display user code and verification URL
- Poll for token completion
- Handle token refresh with auto-refresh
- ✅ Implement logout functionality
- ✅ Store/retrieve tokens from credential store with expiry tracking
- ✅
campus client list- List all clients - ✅
campus client new- Create client - ✅
campus client get- Get client details - ✅
campus client update- Update client metadata - ✅
campus client delete- Delete client - ✅
campus client revoke- Revoke client secret
- ✅
campus client access get- Get client vault permissions - ✅
campus client access grant- Grant vault access - ✅
campus client access revoke- Revoke vault access - ✅
campus client access update- Update vault access
- ✅
campus vault list --vault <label>- List vault keys - ✅
campus vault get --vault <label> [--key <key>]- Get vault/entry - ✅
campus vault set --vault <label> --key <key> --value <value>- Set key-value - ✅
campus vault delete --vault <label> --key <key>- Delete key
- ⏳ Error handling and user-friendly messages
- ⏳ Help text and documentation
- ✅ Package as installable CLI tool via Poetry scripts
- ⏳ Testing
The following resources are available in campus-api-python but not yet exposed in the CLI:
campus timetable list- List all timetablescampus timetable get-current- Get current timetable IDcampus timetable set-current <id>- Set current timetablecampus timetable get-next- Get next timetable IDcampus timetable set-next <id>- Set next timetablecampus timetable get <id>- Get timetable metadatacampus timetable entries <id>- List timetable entries
campus assignment list [--created-by <teacher>]- List assignmentscampus assignment new- Create new assignmentcampus assignment get <id>- Get assignment detailscampus assignment update <id>- Update assignmentcampus assignment delete <id>- Delete assignmentcampus assignment links add <id>- Add classroom link
campus circle list- List circlescampus circle new- Create new circlecampus circle get <id>- Get circle detailscampus circle update <id>- Update circlecampus circle delete <id>- Delete circlecampus circle members list <id>- List circle memberscampus circle members add <id> <member>- Add membercampus circle members remove <id> <member>- Remove member
campus user list- List userscampus user new- Create new usercampus user get <id>- Get user detailscampus user activate <id>- Activate usercampus user delete <id>- Delete user
The CLI uses the campus_python package (from campus-api-python) which provides:
Campusclass - Unified client interfaceauth.clients- OAuth client managementauth.vaults- Vault key-value storageauth.users- User managementapi.timetables- Timetable managementapi.assignments- Assignment managementapi.circles- Circle management
from campus_cli.api import CampusClient
# Get authenticated client (with auto-refresh)
api = get_api_client()
# Access resources
clients = api.auth_clients.list()
client = api.auth_clients[client_id].get()
vault_keys = api.auth_vaults[label].keys()- API errors from
campus_python.errorsare propagated - KeyErrors indicate missing resources (vaults, keys)
- HTTP errors are raised via
raise_for_status()