Sleep Command API Reference¶
This section documents the internals of the sleep
command in Bijux CLI.
bijux_cli.commands.sleep ¶
Implements the sleep
command for the Bijux CLI.
This module provides a simple command to pause execution for a specified duration. It is primarily used for scripting, testing, or rate-limiting operations within automated workflows. The command returns a structured payload confirming the duration slept.
Output Contract
- Success:
{"slept": float}
- Verbose: Adds
{"python": str, "platform": str}
to the payload. - Error:
{"error": str, "code": int}
Exit Codes
0
: Success.1
: Internal or configuration-related error.2
: Invalid argument (e.g., negative duration) or timeout exceeded.
sleep ¶
sleep(
ctx: Context,
seconds: float = Option(
...,
"--seconds",
"-s",
help="Duration in seconds (must be ≥ 0)",
),
quiet: bool = Option(
False, "-q", "--quiet", help=HELP_QUIET
),
verbose: bool = Option(
False, "-v", "--verbose", help=HELP_VERBOSE
),
fmt: str = Option(
"json", "-f", "--format", help=HELP_FORMAT
),
pretty: bool = Option(
True, "--pretty/--no-pretty", help=HELP_NO_PRETTY
),
debug: bool = Option(
False, "-d", "--debug", help=HELP_DEBUG
),
) -> None
Defines the entrypoint and logic for the bijux sleep
command.
This function validates the requested sleep duration against configuration limits, pauses execution, and then emits a structured payload confirming the duration.
Parameters:
-
ctx
(Context
) –The Typer context for the CLI.
-
seconds
(float
, default:Option(..., '--seconds', '-s', help='Duration in seconds (must be ≥ 0)')
) –The duration in seconds to pause execution. Must be non-negative and not exceed the configured command timeout.
-
quiet
(bool
, default:Option(False, '-q', '--quiet', help=HELP_QUIET)
) –If True, suppresses all output except for errors.
-
verbose
(bool
, default:Option(False, '-v', '--verbose', help=HELP_VERBOSE)
) –If True, includes Python and platform details in the output payload.
-
fmt
(str
, default:Option('json', '-f', '--format', help=HELP_FORMAT)
) –The output format, either "json" or "yaml". Defaults to "json".
-
pretty
(bool
, default:Option(True, '--pretty/--no-pretty', help=HELP_NO_PRETTY)
) –If True, pretty-prints the output for human readability.
-
debug
(bool
, default:Option(False, '-d', '--debug', help=HELP_DEBUG)
) –If True, enables debug diagnostics, implying
verbose
andpretty
.
Returns:
-
None
(None
) –
Raises:
-
SystemExit
–Exits with a contract-compliant status code and payload upon any error, such as a negative sleep duration or a timeout violation.
Source code in src/bijux_cli/commands/sleep.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|