Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Command-line interface

raven, the command-line interface for the Raven backend.

Usage

pnpm --filter @raven/cli dev version         # run from source
pnpm --filter @raven/cli build && node cli/dist/index.mjs version
CommandDescription
raven versionCLI version, plus the server and API version of the profile
raven -VCLI version only, with no network call
raven profile add <name> [<api-url>]Add a profile for a server, with no user
raven profile listList profiles; * marks the current one
raven profile use <name>Make a profile the current one
raven profile remove <name> [--yes]Remove a profile, ending its session
raven auth login [<api-url>] [--username <name>] [--password-stdin]Log in with a username or email and password
raven auth logoutEnd the session and delete the token; the profile stays
raven orgs list [--page <n>] [--per-page <n>] [--all]List organizations; site admins also see unlisted ones
raven orgs get <org-slug | org-id>Show an organization; logged-in users also see whether they can edit it
raven auth statusShow the profile, server and user; exit code 3 if the session has expired

Global options, accepted by every command:

OptionDescription
--profile <name>Profile to use. Defaults to RAVEN_PROFILE, then current
--jsonPrint JSON on stdout, and errors as JSON on stderr
--anonymousSend requests without a token

Profiles

A profile is a server plus an optional user, stored in config.toml in the config directory (~/.config/raven, or $XDG_CONFIG_HOME/raven; the OS default on Windows). Tokens are kept in the OS keychain, or in credentials.json (mode 0600) when no keychain is available.

current = "local"

[profiles.local]
apiUrl = "http://localhost:7001"
user = "alice"

[profiles.public]
apiUrl = "https://api.thestacks.org"

With no profile, the CLI uses https://api.thestacks.org anonymously.

VariableEffect
RAVEN_PROFILEProfile to use when --profile isn’t given
RAVEN_API_URLServer to use; the profile’s stored token is then not sent
RAVEN_TOKENToken to send instead of the stored one
RAVEN_CONFIG_DIRConfig directory to use instead of the OS default

Exit codes

CodeMeaning
0Success
1Other error
2Usage error (unknown command, bad option, etc.)
3Authentication or permission error (401, 403)
4Not found (404)
5Validation error (400, 422)
6Network error (server unreachable, timeout)
7Server error (5xx)

Development

ScriptDescription
pnpm dev <args>Run the CLI from source with tsx
pnpm buildBundle to dist/index.mjs with tsdown
pnpm testUnit tests (vitest)
pnpm generate:api [x]Regenerate src/api/openapi.json and src/api/v1.d.ts from a server URL or spec file (default http://localhost:7001)

Commit the regenerated files whenever the v1 API changes. Each command in src/commands/ declares its auth level (none, optional, required) and the v1 routes it calls; auth-levels.test.ts checks the levels against the spec.