Skip to content

Conversation

@TheMarstonConnell
Copy link
Member

@TheMarstonConnell TheMarstonConnell commented Jan 2, 2026

Add new 'sequoia config' subcommands to read and modify configuration values:

  • config get <key> - retrieves a config value by key (supports dot notation for nested values)
  • config set <key> <value> - sets a config value and writes to config.yaml
  • config show - displays the entire configuration

Examples:
sequoia config get queue_interval sequoia config set queue_interval 50 sequoia config get api_config.port sequoia config set api_config.port 8080

Summary by CodeRabbit

  • New Features
    • Added a config command with show, get, and set subcommands to view, retrieve, and update configuration settings.
    • Supports nested configuration access via dot notation.
    • Type-aware handling for strings, integers, floats, and booleans when setting values.
    • Changes are persisted to the configuration file and surface errors for invalid keys or conversions.

✏️ Tip: You can customize this high-level summary in your review settings.

Add new 'sequoia config' subcommands to read and modify configuration values:
- `config get <key>` - retrieves a config value by key (supports dot notation for nested values)
- `config set <key> <value>` - sets a config value and writes to config.yaml
- `config show` - displays the entire configuration

Examples:
  sequoia config get queue_interval
  sequoia config set queue_interval 50
  sequoia config get api_config.port
  sequoia config set api_config.port 8080
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 2, 2026

📝 Walkthrough

Walkthrough

Adds a new config CLI subcommand (cmd/config/config.go) providing config with show, get, and set subcommands. The implementation initializes and exports configuration, traverses and updates nested fields via reflection using dot-separated keys, performs type-aware parsing for common scalar types, writes updated configuration to the config file, and reports errors on invalid keys or conversions. The root command is updated to register the new ConfigCmd() so the config command is available.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add CLI commands for config management' directly and clearly summarizes the main change: introducing new CLI subcommands for managing configuration (get, set, show).
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d4ca8b6 and 48b3576.

📒 Files selected for processing (1)
  • cmd/config/config.go
🧰 Additional context used
🧬 Code graph analysis (1)
cmd/config/config.go (3)
cmd/types/flags.go (1)
  • FlagHome (4-4)
config/files.go (2)
  • Init (76-107)
  • ConfigFileName (15-15)
config/types.go (1)
  • Config (22-35)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: lint
🔇 Additional comments (8)
cmd/config/config.go (8)

1-15: LGTM!

The imports are well-organized and appropriate for the reflection-based config manipulation. The potential naming overlap with config package is handled correctly via aliasing in root.go.


17-27: LGTM!

Clean parent command structure following cobra conventions.


29-54: LGTM!

The show command correctly loads and exports the full configuration with proper error handling.


56-90: LGTM!

Well-documented get command with helpful examples demonstrating dot notation for nested values. The argument validation and error handling are correct.


134-143: LGTM!

Good use of restrictive file permissions (0600) to protect potentially sensitive configuration values.


145-168: LGTM!

The struct-to-YAML serialization (lines 158-165) provides user-friendly output when querying nested configuration sections like api_config.


194-227: LGTM!

Good use of field.Type().Bits() in the integer/float parsing calls (lines 199, 205, 211) to prevent silent overflow when setting smaller-width fields like int16.


229-268: LGTM!

Comprehensive field lookup checking yaml tags, mapstructure tags, and field names provides robust key resolution that aligns with the Config struct's tag annotations.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 965e84f and d4ca8b6.

📒 Files selected for processing (2)
  • cmd/config/config.go
  • cmd/root.go
🧰 Additional context used
🧬 Code graph analysis (2)
cmd/root.go (1)
cmd/config/config.go (1)
  • ConfigCmd (17-26)
cmd/config/config.go (3)
cmd/types/flags.go (1)
  • FlagHome (4-4)
config/files.go (2)
  • Init (76-107)
  • ConfigFileName (15-15)
config/types.go (1)
  • Config (22-35)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Build
  • GitHub Check: cov
  • GitHub Check: Test
  • GitHub Check: lint
🔇 Additional comments (5)
cmd/root.go (1)

9-9: LGTM!

The import alias configcmd appropriately avoids conflict with the existing config package import, and the new subcommand is wired consistently with other subcommands like wallet.WalletCmd() and database.DataCmd().

Also applies to: 179-179

cmd/config/config.go (4)

16-26: LGTM!

Clean implementation of the parent command following standard Cobra patterns.


28-53: LGTM!

Proper error handling and reuse of existing Export() method for serialization.


55-89: LGTM!

Well-documented command with helpful examples and proper argument validation via cobra.ExactArgs(1).


219-258: LGTM!

Robust implementation that correctly handles pointer dereferencing, parses tag options (e.g., omitempty), and provides multiple lookup strategies (yaml tag, mapstructure tag, field name).

Comment on lines +121 to +125
// Write the updated config back to file
directory := os.ExpandEnv(home)
if err := writeConfigFile(directory, cfg); err != nil {
return err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider reusing the resolved directory from config.Init for consistency.

os.ExpandEnv(home) is called here, but config.Init also performs the same expansion internally. While currently harmless, if the expansion logic ever diverges, the write path might not match the read path. Consider either:

  1. Exposing the resolved directory from config.Init, or
  2. Extracting a shared helper function for directory resolution.
🤖 Prompt for AI Agents
In cmd/config/config.go around lines 121 to 125, the code calls
os.ExpandEnv(home) here but config.Init already resolves/expands the same home
path, which can lead to divergence; change this to reuse the resolved directory
from config.Init (or add a shared helper in the config package that performs the
expansion and use that in both Init and this write path) so the read and write
paths use the identical resolved directory; update call sites to use the new
exported resolved path or helper and ensure writeConfigFile is passed that
resolved directory.

- Change file permissions from 0644 to 0600 for security (config may contain sensitive values)
- Fix potential integer overflow by using field.Type().Bits() instead of hardcoded 64
- Improve struct handling by serializing nested config sections as YAML for better readability
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.

3 participants