Skip to content

Conversation

@plx
Copy link
Owner

@plx plx commented Jul 31, 2025

Summary

  • Replaced all ad-hoc environment variable handling with clap's built-in env attribute
  • Added hidden global parameters for execution mode and log level configuration
  • Cleaned up redundant std::env::var() calls throughout the codebase

Changes

Added hidden global parameters

  • --log-level: Reads from AGENTIC_NAVIGATION_GUIDE_LOG_MODE (values: quiet, default, verbose)
  • --execution-mode: Reads from AGENTIC_NAVIGATION_GUIDE_EXECUTION_MODE (values: default, post-tool-use, pre-commit-hook)
  • Both parameters are hidden from help output and have proper conflict resolution with convenience flags

Updated command arguments

  • VerifyArgs:
    • guide parameter now uses env = "AGENTIC_NAVIGATION_GUIDE_PATH"
    • root parameter now uses env = "AGENTIC_NAVIGATION_GUIDE_ROOT"
  • CheckArgs:
    • guide parameter now uses env = "AGENTIC_NAVIGATION_GUIDE_PATH"
  • DumpArgs:
    • root parameter now uses env = "AGENTIC_NAVIGATION_GUIDE_ROOT"
  • InitArgs:
    • root parameter now uses env = "AGENTIC_NAVIGATION_GUIDE_ROOT"

Implementation details

  • Removed all manual std::env::var() calls for the above parameters
  • Implemented proper conflict resolution between convenience flags (--verbose, --quiet) and the hidden --log-level parameter
  • Preserved the AGENTIC_NAVIGATION_GUIDE_NAME fallback logic as a special case
  • Updated Cli::build_config() to use the new parameter-based approach

Testing

  • ✅ All existing tests pass
  • ✅ Environment variables are correctly read and displayed in help output
  • ✅ Conflict detection between flags works as expected
  • ✅ Code passes cargo fmt and cargo clippy -- -D warnings

Benefits

  • Cleaner, more maintainable code
  • Better consistency by leveraging clap's built-in functionality
  • Environment variable values are now visible in help output
  • Reduced boilerplate code

🤖 Generated with Claude Code

plx and others added 2 commits July 31, 2025 08:45
This commit replaces all ad-hoc environment variable handling with clap's
built-in `env` attribute. The changes include:

- Add hidden global parameters --log-level and --execution-mode that read
  from their respective environment variables
- Update all command arguments to use the env attribute:
  - VerifyArgs: guide uses AGENTIC_NAVIGATION_GUIDE_PATH, root uses AGENTIC_NAVIGATION_GUIDE_ROOT
  - CheckArgs: guide uses AGENTIC_NAVIGATION_GUIDE_PATH
  - DumpArgs: root uses AGENTIC_NAVIGATION_GUIDE_ROOT
  - InitArgs: root uses AGENTIC_NAVIGATION_GUIDE_ROOT
- Remove all manual std::env::var() calls for these parameters
- Implement proper conflict resolution between convenience flags and direct parameters
- Preserve AGENTIC_NAVIGATION_GUIDE_NAME fallback logic as a special case

This makes the code cleaner, more maintainable, and leverages clap's
built-in functionality for better consistency.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Update --post-tool-use-hook and --pre-commit-hook to properly conflict
with both --execution-mode AND each other using conflicts_with_all.
This ensures mutually exclusive usage of these execution mode options.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@plx plx merged commit 1a89aa6 into main Jul 31, 2025
6 checks passed
@plx plx deleted the refactor/use-clap-env-vars branch July 31, 2025 15:03
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