Config Module API Reference¶
This section documents the internals of the config
module in Bijux CLI.
bijux_cli.contracts.config ¶
Defines the contract for the application configuration service.
This module specifies the ConfigProtocol
, a formal interface that any configuration management service within the application must implement. This ensures a consistent API for loading, accessing, modifying, and persisting key-value settings, promoting modularity and testability.
ConfigProtocol ¶
Bases: Protocol
Defines the contract for application configuration management.
This interface specifies the methods for loading, accessing, modifying, and persisting configuration data from various sources (e.g., .env, JSON, or YAML files).
all ¶
Returns all configuration key-value pairs.
Returns:
-
dict[str, str]
–dict[str, str]: A dictionary of all configuration data.
clear ¶
delete ¶
Deletes a configuration key and persists the change.
Parameters:
-
key
(str
) –The key to delete.
Returns:
-
None
(None
) –
export ¶
Exports the current configuration to a file.
Parameters:
-
path
(str | Path
) –The path to the destination file.
-
out_format
(str | None
, default:None
) –The desired output format (e.g., 'env'). If None, the format may be inferred from the path.
Returns:
-
None
(None
) –
Source code in src/bijux_cli/contracts/config.py
get ¶
Retrieves a configuration value by its key.
Parameters:
-
key
(str
) –The key of the value to retrieve.
-
default
(Any
, default:None
) –The value to return if the key is not found.
Returns:
-
Any
(Any
) –The configuration value or the provided default.
Source code in src/bijux_cli/contracts/config.py
list_keys ¶
Returns a list of all configuration keys.
Returns:
-
list[str]
–list[str]: A list of all keys present in the configuration.
load ¶
Loads configuration from a specified file path.
Parameters:
-
path
(str | Path | None
, default:None
) –The path to the configuration file. If None, the service may load from a default location.
Returns:
-
None
(None
) –
Source code in src/bijux_cli/contracts/config.py
reload ¶
save ¶
set ¶
Sets a configuration key and persists the change.
Parameters:
-
key
(str
) –The key to set or update.
-
value
(Any
) –The value to associate with the key.
Returns:
-
None
(None
) –
unset ¶
Removes a configuration key from the current in-memory session.
Unlike delete
, this operation may not be immediately persisted to the source file.
Parameters:
-
key
(str
) –The key to remove from the in-memory configuration.
Returns:
-
None
(None
) –