Skip to content

feat(cli): prioritize local config and fix arg parsing#184

Open
dandye wants to merge 4 commits intogoogle:mainfrom
dandye:cli_arg_order
Open

feat(cli): prioritize local config and fix arg parsing#184
dandye wants to merge 4 commits intogoogle:mainfrom
dandye:cli_arg_order

Conversation

@dandye
Copy link
Contributor

@dandye dandye commented Feb 12, 2026

Fixes global flag parsing order and adds local configuration support.

Changes

  • CLI Argument Parsing: Fixed issue where global flags (e.g., --output) were ignored when placed after subcommands.
  • Local Configuration: Added support for ./.secops/config.json in the current directory, which overrides global settings.
  • Environment Variable Support: Added SECOPS_LOCAL_CONFIG_DIR to specify a custom directory for local configuration.
  • Requirements: Split dependencies into requirements.txt and requirements-dev.txt.

Examples

Managing Multiple Configurations

You can use SECOPS_LOCAL_CONFIG_DIR to switch between different configurations without changing directories:

# Setup configuration for Project A (e.g. in /path/to/project-a)
export SECOPS_LOCAL_CONFIG_DIR=/path/to/project-a/.secops
mkdir -p $SECOPS_LOCAL_CONFIG_DIR
secops config set --local --project-id project-a

# Setup configuration for Project B
export SECOPS_LOCAL_CONFIG_DIR=/path/to/project-b/.secops
mkdir -p $SECOPS_LOCAL_CONFIG_DIR
secops config set --local --project-id project-b

# Use Project A config
export SECOPS_LOCAL_CONFIG_DIR=/path/to/project-a/.secops
secops search ...

Verification

  • Verified secops help --output json works as expected.
  • Verified local config overrides global config.

- Fixes global flag parsing order (e.g., )
- Implementation of local configuration support () with precedence over global config
- Adds  flag to  command
- Splits dependencies into  and
@dandye dandye requested a review from mihirvala08 as a code owner February 12, 2026 20:25
# Optimization: If --local, maybe we should only load local config?
# But load_config() returns merged.
# Let's use load_config() but be aware we might save merged values to local.
config = load_config()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have params in load_config to determine which config to return? If no param is specified, we can load merged config (local being prioritized). That way we, set command will only mutate respective config's value instead of merged values.

Comment on lines 31 to 34
for option_string in args:
if option_string in parser._option_string_actions:
return
parser.add_argument(*args, **kwargs)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for option_string in args:
if option_string in parser._option_string_actions:
return
parser.add_argument(*args, **kwargs)
try:
parser.add_argument(*args, **kwargs)
except argparse.ArgumentError:
# Argument already exists, so we can skip it
return

@mihirvala08
Copy link
Collaborator

/run-integration-tests 9fa9f6f

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.

2 participants

Comments