Docs Command API Reference¶
This section documents the internals of the docs
command in Bijux CLI.
bijux_cli.commands.docs ¶
Docs command for the Bijux CLI.
Generates a machine-readable specification of the entire CLI, outputting it as JSON or YAML. This command is designed for automation, enabling integration with external documentation tools or APIs. It supports outputting to stdout or a file and ensures all text is ASCII-safe.
Output Contract
- Success (file):
{"status": "written", "file": "<path>"}
- Success (stdout): The raw specification string is printed directly.
- Spec fields:
{"version": str, "commands": list, ...}
- Verbose: Adds
{"python": str, "platform": str}
to the spec. - Error:
{"error": str, "code": int}
Exit Codes
0
: Success.1
: Fatal or internal error.2
: CLI argument, flag, or format error.3
: ASCII or encoding error.
docs ¶
docs(
ctx: Context,
out: Path | None = OUT_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 docs
command.
This function orchestrates the entire specification generation process. It validates CLI flags, checks for ASCII-safe environment variables, resolves the output destination, builds the specification payload, and writes the result to a file or stdout. All errors are handled and emitted in a structured format before exiting with a specific code.
Parameters:
-
ctx
(Context
) –The Typer context, used for managing command state.
-
out
(Path | None
, default:OUT_OPTION
) –The output destination: a file path, a directory, or '-' to signify stdout.
-
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 metadata in the spec.
-
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 the application with a contract-compliant status code and payload upon any error, including argument validation, ASCII violations, serialization failures, or I/O issues.
Source code in src/bijux_cli/commands/docs.py
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 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 |
|