Export Command API Reference¶
This section documents the internals of the export
command in Bijux CLI.
bijux_cli.commands.config.export ¶
Implements the config export
subcommand for the Bijux CLI.
This module contains the logic for exporting the application's entire current configuration to a specified destination, which can be a file or standard output. The output format can be explicitly set to 'env', 'json', or 'yaml', or it can be inferred from the destination file's extension.
Output Contract
- Success (to file):
{"status": "exported", "file": str, "format": str}
- Success (to stdout): The raw exported configuration data is printed directly.
- Verbose (to file): Adds
{"python": str, "platform": str}
to the payload. - Error:
{"error": str, "code": int}
Exit Codes
0
: Success.1
or2
: An error occurred during the export process, such as a file write error or invalid format request.
export_config ¶
export_config(
ctx: Context,
path: str = Argument(
...,
help="Destination file – use “-” to write to STDOUT",
),
out_fmt: str = Option(
None,
"--out-format",
help="Force output format: env | json | yaml",
),
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
Exports the current configuration to a file or standard output.
This function writes all configuration key-value pairs to a specified destination. If the destination is a file path, a structured JSON/YAML confirmation message is printed to stdout upon success. If the destination is "-", the raw exported configuration is printed directly to stdout.
Parameters:
-
ctx
(Context
) –The Typer context for the CLI.
-
path
(str
, default:Argument(..., help='Destination file – use “-” to write to STDOUT')
) –The destination file path, or "-" for standard output.
-
out_fmt
(str
, default:Option(None, '--out-format', help='Force output format: env | json | yaml')
) –The desired output format ('env', 'json', 'yaml'). If unspecified, it is inferred from the file extension.
-
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/platform details in the confirmation payload (file export only).
-
fmt
(str
, default:Option('json', '-f', '--format', help=HELP_FORMAT)
) –The format for the confirmation payload ("json" or "yaml").
-
pretty
(bool
, default:Option(True, '--pretty/--no-pretty', help=HELP_NO_PRETTY)
) –If True, pretty-prints the confirmation payload.
-
debug
(bool
, default:Option(False, '-d', '--debug', help=HELP_DEBUG)
) –If True, enables debug diagnostics.
Returns:
-
None
(None
) –
Raises:
-
SystemExit
–Always exits with a contract-compliant status code and payload, indicating success or detailing the error.
Source code in src/bijux_cli/commands/config/export.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 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 |
|