Repl Command API Reference¶
This section documents the internals of the repl
command in Bijux CLI.
bijux_cli.commands.repl ¶
Implements the interactive Read-Eval-Print Loop (REPL) for the Bijux CLI.
This module provides a rich, interactive shell for executing Bijux CLI commands. It enhances the user experience with features like persistent command history, context-aware tab-completion, and a colorized prompt. Users can chain multiple commands on a single line using semicolons. The REPL can also operate in a non-interactive mode to process commands piped from stdin.
The REPL itself operates in a human-readable format. When executing commands, it respects global flags like --format
or --quiet
for those specific invocations.
Exit Codes
0
: The REPL session was exited cleanly (e.g., viaexit
,quit
, Ctrl+D, or a caught signal).2
: An invalid flag was provided to therepl
command itself (e.g.,--format=json
).
CommandCompleter ¶
Bases: Completer
Provides context-aware tab-completion for the REPL.
Initializes the completer.
Parameters:
-
main_app
(Typer
) –The root Typer application whose commands and options will be used for completion suggestions.
Source code in src/bijux_cli/commands/repl.py
get_completions ¶
Yields completion suggestions for the current input.
Parameters:
-
document
(Document
) –The current
prompt_toolkit
document. -
_complete_event
(CompleteEvent
) –The completion event (unused).
Yields:
-
Completion
(Completion
) –A
prompt_toolkit
Completion
object.
Source code in src/bijux_cli/commands/repl.py
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 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 |
|
get_prompt ¶
Returns the REPL prompt string.
The prompt is styled with ANSI colors unless NO_COLOR
or a test mode environment variable is set.
Returns:
-
str | ANSI
–str | ANSI: The prompt string, which may include ANSI color codes.
Source code in src/bijux_cli/commands/repl.py
main ¶
main(
ctx: Context,
quiet: bool = Option(
False, "-q", "--quiet", help=HELP_QUIET
),
verbose: bool = Option(
False, "-v", "--verbose", help=HELP_VERBOSE
),
fmt: str = Option(
"human", "-f", "--format", help=HELP_FORMAT_HELP
),
pretty: bool = Option(
True, "--pretty/--no-pretty", help=HELP_NO_PRETTY
),
debug: bool = Option(
False, "-d", "--debug", help=HELP_DEBUG
),
) -> None
Defines the entrypoint for the bijux repl
command.
This function initializes the REPL environment. It validates flags, sets up signal handlers for clean shutdown, and dispatches to either the non-interactive (piped) mode or the interactive async prompt loop.
Parameters:
-
ctx
(Context
) –The Typer context for the CLI.
-
quiet
(bool
, default:Option(False, '-q', '--quiet', help=HELP_QUIET)
) –If True, forces non-interactive mode and suppresses prompts and command output.
-
verbose
(bool
, default:Option(False, '-v', '--verbose', help=HELP_VERBOSE)
) –If True, enables verbose output for subcommands.
-
fmt
(str
, default:Option('human', '-f', '--format', help=HELP_FORMAT_HELP)
) –The desired output format. Only "human" is supported for the REPL itself.
-
pretty
(bool
, default:Option(True, '--pretty/--no-pretty', help=HELP_NO_PRETTY)
) –If True, enables pretty-printing for subcommands.
-
debug
(bool
, default:Option(False, '-d', '--debug', help=HELP_DEBUG)
) –If True, enables debug diagnostics for subcommands.
Returns:
-
None
(None
) –