P2-9: CLI Tool
Status
Complete — branch feat/P2-9-cli-tool, 22 tests passing.
What was built
Click-based CLI (app/cli/) wrapping the management API (P2-4).
Commands
| Command | Description |
|---|---|
wikibot login |
Browser OAuth flow with localhost callback server |
wikibot wiki create <slug> |
Create wiki (options: --name, --purpose) |
wikibot wiki list |
List wikis in table format |
wikibot wiki delete <slug> |
Delete wiki (confirmation prompt, --yes to skip) |
wikibot wiki token <slug> |
Regenerate MCP token |
wikibot wiki grant <slug> <email> <role> |
Grant access (owner/editor/viewer) |
wikibot wiki revoke <slug> <email> |
Revoke access (resolves email to grantee_id) |
Files
app/cli/__init__.py— empty package initapp/cli/auth.py— token storage (~/.wikibot/token), config, auth header helperapp/cli/main.py— all CLI commandstests/test_cli.py— 22 tests (CliRunner + unittest.mock)
Design decisions
- Token stored as plaintext at
~/.wikibot/tokenwith0600permissions - API URL configurable via
WIKIBOT_API_URLenv var (default:https://dev.wikibot.io) - Login uses
http.server.HTTPServeron a random port for the OAuth callback - Revoke resolves email to grantee_id by fetching the ACL list first
Dependencies
click— not currently in project requirements, needs to be addedrequests— already available