Audit Command API Reference¶
This section documents the internals of the audit
command in Bijux CLI.
bijux_cli.commands.audit ¶
Audit command for the Bijux CLI.
Audits the current environment and configuration, emitting machine-readable structured output in JSON or YAML. Supports dry-run simulation and writing results to a file. Handles ASCII hygiene and structured error contracts. Output is automation-safe and suitable for scripting or monitoring.
Output Contract
- Success:
{"status": "completed"}
- Dry-run:
{"status": "dry-run"}
- Written:
{"status": "written", "file": "<path>"}
- Verbose:
{"python": str, "platform": str}
- Error:
{"error": str, "code": int}
Exit Codes
0
: Success, dry-run, or write success.1
: Unexpected/internal error.2
: CLI argument/flag/format or output-path error.3
: ASCII/encoding error.
audit ¶
audit(
ctx: Context,
dry_run: bool = DRY_RUN_OPTION,
output: Path | None = OUTPUT_OPTION,
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 audit
command.
This function orchestrates the entire audit process. It validates all CLI flags and arguments, performs environment checks (e.g., for non-ASCII characters), builds the appropriate result payload, and emits it to stdout or a file in the specified format. All errors are handled and emitted in a structured format before exiting with a specific code.
Parameters:
-
ctx
(Context
) –The Typer context, used to manage command state and detect stray arguments.
-
dry_run
(bool
, default:DRY_RUN_OPTION
) –If True, simulates the audit and reports a "dry-run" status without performing actions.
-
output
(Path | None
, default:OUTPUT_OPTION
) –If a path is provided, writes the audit result to the specified file instead of stdout.
-
quiet
(bool
, default:Option(False, '-q', '--quiet', help=HELP_QUIET)
) –If True, suppresses all output except for errors. The exit code is the primary indicator of the outcome.
-
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. This is overridden by
debug
. -
debug
(bool
, default:Option(False, '-d', '--debug', help=HELP_DEBUG)
) –If True, enables debug diagnostics, which implies
verbose
andpretty
.
Returns:
-
None
(None
) –
Raises:
-
SystemExit
–Exits with a status code and structured error payload upon validation failures (e.g., bad arguments, ASCII errors), I/O issues, or unexpected exceptions. The exit code follows the contract defined in the module docstring.
Source code in src/bijux_cli/commands/audit.py
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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 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 220 221 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 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
|