Context
provide.foundation.context
¶
TODO: Add module docstring.
Classes¶
CLIContext
¶
Bases: RuntimeConfig
Runtime context for CLI execution and state management.
Manages CLI-specific settings, output formatting, and runtime state during command execution. Supports loading from files, environment variables, and programmatic updates during CLI command execution.
Attributes¶
Functions¶
__attrs_post_init__
¶
copy
¶
freeze
¶
Freeze context to prevent further modifications.
from_dict
classmethod
¶
Create context from dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
Dictionary with context values |
required |
source
|
ConfigSource
|
Source of the configuration data |
RUNTIME
|
Returns:
| Type | Description |
|---|---|
CLIContext
|
New CLIContext instance |
Source code in provide/foundation/context/core.py
load_config
¶
Load configuration from file.
Supports TOML, JSON, and YAML formats based on file extension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to configuration file |
required |
Source code in provide/foundation/context/core.py
merge
¶
Merge with another context, with other taking precedence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
CLIContext
|
CLIContext to merge with |
required |
override_defaults
|
bool
|
If False, only override if other's value differs from its class default |
False
|
Returns:
| Type | Description |
|---|---|
CLIContext
|
New merged CLIContext instance |
Source code in provide/foundation/context/core.py
save_config
¶
Save configuration to file.
Format is determined by file extension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to save configuration |
required |
Source code in provide/foundation/context/core.py
to_dict
¶
Convert context to dictionary.
Source code in provide/foundation/context/core.py
update_from_env
¶
Update context from environment variables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prefix
|
str
|
Environment variable prefix (default: PROVIDE) |
'PROVIDE'
|