Skip to content

Add CLI config environment and file parameters to use_client decorator#451

Merged
leoschwarz merged 2 commits intomainfrom
cli-env-param
Mar 13, 2026
Merged

Add CLI config environment and file parameters to use_client decorator#451
leoschwarz merged 2 commits intomainfrom
cli-env-param

Conversation

@leoschwarz
Copy link
Copy Markdown
Member

Fixes #358

The use_client decorator now injects two optional keyword parameters into all decorated functions:

  • config_env: Override the config environment (e.g., 'TEST'). Falls back to BFABRICPY_CONFIG_ENV environment variable or the config file default.
  • config_file: Override the config file path (default: ~/.bfabricpy.yml).

The use_client decorator now injects two optional keyword parameters into
all decorated functions:

- config_env: Override the config environment (e.g., 'TEST'). Falls back to
  BFABRICPY_CONFIG_ENV environment variable or the config file default.
- config_file: Override the config file path (default: ~/.bfabricpy.yml).

This enhancement allows CLI commands and scripts to dynamically override
their configuration without modifying config files or environment variables,
providing greater flexibility for testing and working with multiple
B-Fabric environments.

The parameters are added to function signatures with proper cyclopts.Parameter
annotations for CLI help text when cyclopts is available, with graceful fallback
when it is not.

This affects:
- bfabric (core implementation)
- bfabric_scripts (all scripts using use_client)
- bfabric_app_runner (all CLI commands using use_client)

Tests: All 368 tests pass, including 20 new tests for the feature.
@leoschwarz leoschwarz merged commit 77beb79 into main Mar 13, 2026
3 checks passed
@leoschwarz leoschwarz deleted the cli-env-param branch March 13, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow specifying the config env through bfabric-cli

1 participant