CLI App
Main CLI application entry point.
Main CLI application entry point.
This module defines the qsh command-line application, its top-level callback,
and a set of built-in commands. Plugins are discovered and loaded lazily to
keep startup fast.
Examples: Running the CLI and showing help::
qsh --help
Starting the REPL with a specific context and JSON output::
qsh --context prod --output json repl
Listing tasks with the context's ``m2m`` auth provider instead of its default::
qsh --auth m2m tasks list
Printing shell completion for zsh::
qsh completion zsh > ~/.zsh/completions/_qsh
OutputFormat
Bases: str, Enum
flowchart TD
qsh.cli.app.OutputFormat[OutputFormat]
click qsh.cli.app.OutputFormat href "" "qsh.cli.app.OutputFormat"
Output format options for the CLI.
app_callback
app_callback(context: Annotated[str | None, Option('--context', help='Select context from config')] = None, auth: Annotated[str | None, Option('--auth', metavar='PROVIDER', help='Auth provider from the current context for API commands and auth whoami (overrides the plugin and default auth_provider)')] = None, output: Annotated[OutputFormat | None, Option('-o', '--output', help='Output format: table|json')] = None, verbose: Annotated[bool, Option('--verbose', '-v', help='Enable verbose logging')] = False, wrap: Annotated[bool, Option('--wrap', help='Allow multiline wrapping in table output')] = False, private: Annotated[bool, Option('--private', help='Use private API endpoints (requires super admin access)')] = False) -> None
CLI for QuEra's Quantum Computing Service.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
Annotated[str | None, Option('--context', help='Select context from config')]
|
Optional config context to use for this invocation. |
None
|
auth
|
Annotated[str | None, Option('--auth', metavar='PROVIDER', help='Auth provider from the current context for API commands and auth whoami (overrides the plugin and default auth_provider)')]
|
Optional |
None
|
output
|
Annotated[OutputFormat | None, Option('-o', '--output', help='Output format: table|json')]
|
Optional output format override ("table" or "json"). |
None
|
verbose
|
Annotated[bool, Option('--verbose', '-v', help='Enable verbose logging')]
|
Enable verbose logging for diagnostics. |
False
|
wrap
|
Annotated[bool, Option('--wrap', help='Allow multiline wrapping in table output')]
|
Allow multiline wrapping in table output. |
False
|
private
|
Annotated[bool, Option('--private', help='Use private API endpoints (requires super admin access)')]
|
Use private API endpoints (requires super admin access). |
False
|
Source code in qsh/cli/app.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
clear_app_context_cache
clear_app_context_cache() -> None
Clear the cached AppContext and config to force reload next time.
Source code in qsh/cli/app.py
338 339 340 341 342 343 | |
clear_context_bound_auth_providers
clear_context_bound_auth_providers() -> None
Drop in-memory auth providers so the next use rebuilds from the active context.
Providers are keyed only by name in the process-global registry. After a context switch, stale instances retain the previous context's audience and other settings. Unregistering discards in-memory objects only; it does not call logout or delete context-isolated credential caches.
Source code in qsh/cli/app.py
346 347 348 349 350 351 352 353 354 355 356 357 | |
cli_main
cli_main() -> None
Main entry point that loads plugins only when needed.
This function may terminate the process with a non-zero exit code on error.
Source code in qsh/cli/app.py
535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 | |
completion_command
completion_command(shell: Annotated[str, Argument(help='Shell type: bash, zsh, fish, or powershell')]) -> None
Generate shell completion scripts for the given shell.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shell
|
Annotated[str, Argument(help='Shell type: bash, zsh, fish, or powershell')]
|
Target shell ( |
required |
Raises:
| Type | Description |
|---|---|
typer.Exit
|
If the shell is unsupported. Examples: qsh completion bash > ~/.qsh_completion source ~/.qsh_completion qsh completion zsh > ~/.zsh/completions/_qsh qsh completion fish > ~/.config/fish/completions/qsh.fish |
Source code in qsh/cli/app.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 | |
context_list
context_list(output: str | None = typer.Option(None, '-o', '--output', help='Output format (json, table).')) -> None
List all configured contexts.
Source code in qsh/cli/app.py
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 | |
context_set
context_set(name: str = typer.Argument(..., help='Context name to set as active.')) -> None
Set the active context in config and the current process.
Updates sticky session state (including a startup --context override)
and clears cached AppContext config. When the effective context changes,
it unregisters in-memory auth providers so the next auth use rebuilds from
the new context without logout.
Source code in qsh/cli/app.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
context_show
context_show(output: str | None = typer.Option(None, '-o', '--output', help='Output format (json, table).')) -> None
Display the current active context name.
Source code in qsh/cli/app.py
365 366 367 368 369 370 371 372 373 374 | |
create_app_context
create_app_context() -> 'AppContext'
Create and cache an AppContext populated from current CLI state.
The context and settings are cached across invocations during a single process run to avoid repeated disk I/O.
Returns:
| Type | Description |
|---|---|
'AppContext'
|
Initialized |
Source code in qsh/cli/app.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | |
help_command
help_command(ctx: Context) -> None
Show help for QSH commands (equivalent to qsh --help).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
Typer context (unused; kept for parity with Typer conventions). |
required |
Source code in qsh/cli/app.py
461 462 463 464 465 466 467 468 469 470 | |
load_plugins
load_plugins(app: Typer, ctx_provider: Callable[[], 'AppContext']) -> None
Lazy wrapper around plugin loading.
This keeps plugin discovery imports out of module import time for fast built-ins
like qsh version and qsh completion.
Source code in qsh/cli/app.py
100 101 102 103 104 105 106 107 108 | |
main
main() -> None
Entry point for the qsh command.
Source code in qsh/cli/app.py
559 560 561 | |
repl_command
repl_command() -> None
Start an interactive REPL session.
The REPL provides an interactive shell where you can run QSH commands without having to type 'qsh' before each command. It supports tab completion and maintains the current context config.
Examples: qsh repl # Start interactive shell qsh --context prod repl # Start REPL with specific context
Source code in qsh/cli/app.py
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | |
setup_logging
setup_logging(verbose: bool = False) -> logging.Logger
Configure logging with a rich handler and return the main logger.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbose
|
bool
|
Enable verbose log level (DEBUG) when True, otherwise WARNING. |
False
|
Returns:
| Type | Description |
|---|---|
Logger
|
Configured logger named |
Source code in qsh/cli/app.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
version_command
version_command() -> None
Show version information.
Source code in qsh/cli/app.py
473 474 475 476 477 478 | |