Skip to content

fix(config): correct pitchfork config add to generate valid TOML#258

Merged
jdx merged 2 commits intojdx:mainfrom
benjaminwestern:main
Feb 25, 2026
Merged

fix(config): correct pitchfork config add to generate valid TOML#258
jdx merged 2 commits intojdx:mainfrom
benjaminwestern:main

Conversation

@benjaminwestern
Copy link
Contributor

Previously, 'pitchfork config add' simply joined all arguments into the 'run' field as a string, causing execution errors when users tried to pass CLI flags:

run = "--cmd 'bun run server' --retry 3 --watch 'src/**/*.ts'"
retry = 0

This generated broken TOML that caused errors like:
sh: line 0: exec: --: invalid option
exec: usage: exec [-cl] [-a name] file [redirection ...]

Now the command accepts proper CLI flags for each daemon configuration option:
--run, --retry, --watch, --dir, --env, --depends, --ready-*
--autostart, --autostop, --boot-start, --on-ready, --on-fail, --on-retry
--cron-schedule, --cron-retrigger

This generates correct TOML with each option as a separate field:
run = "bun run server"
retry = 3
watch = ["src/**/*.ts"]

Changes:

  • Added 20+ CLI flags for all daemon configuration options
  • Fixed error handling to use bail!() macro (consistent with codebase)
  • Made struct fields private (consistent with codebase patterns)
  • Added comprehensive long_about documentation with examples
  • Added 14 e2e tests and 6 unit tests for validation
  • Added create_project_dir() helper to test common module
  • Updated CLI documentation via usage spec generation

Fixes broken config generation bug. Users can now safely use 'pitchfork config add' instead of manually editing pitchfork.toml.

Co-written with Kimi K2.5 and Gemini 3.0 Pro Preview

Previously, 'pitchfork config add' simply joined all arguments into the 'run'
field as a string, causing execution errors when users tried to pass CLI flags:

  run = "--cmd 'bun run server' --retry 3 --watch 'src/**/*.ts'"
  retry = 0

This generated broken TOML that caused errors like:
  sh: line 0: exec: --: invalid option
  exec: usage: exec [-cl] [-a name] file [redirection ...]

Now the command accepts proper CLI flags for each daemon configuration option:
  --run, --retry, --watch, --dir, --env, --depends, --ready-*
  --autostart, --autostop, --boot-start, --on-ready, --on-fail, --on-retry
  --cron-schedule, --cron-retrigger

This generates correct TOML with each option as a separate field:
  run = "bun run server"
  retry = 3
  watch = ["src/**/*.ts"]

Changes:
- Added 20+ CLI flags for all daemon configuration options
- Fixed error handling to use bail!() macro (consistent with codebase)
- Made struct fields private (consistent with codebase patterns)
- Added comprehensive long_about documentation with examples
- Added 14 e2e tests and 6 unit tests for validation
- Added create_project_dir() helper to test common module
- Updated CLI documentation via usage spec generation

Fixes broken config generation bug. Users can now safely use
'pitchfork config add' instead of manually editing pitchfork.toml.

Co-authored-by: Kimi K2.5 <kimi-k2.5@example.com>
Co-authored-by: Gemini 3.0 Pro Preview <gemini-3.0-pro@example.com>
@gemini-code-assist
Copy link

Summary of Changes

Hello @benjaminwestern, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the pitchfork config add command by introducing explicit CLI flags for all daemon configuration options. This change addresses a critical bug where the command previously generated invalid TOML, causing daemon execution failures. By allowing users to specify configuration parameters via dedicated flags, the PR ensures robust and correct TOML file generation, making the config add command reliable for managing daemon configurations without manual file editing.

Highlights

  • Enhanced config add command: The pitchfork config add command now accepts over 20 explicit CLI flags for daemon configuration options, replacing the previous method of joining all arguments into a single 'run' field.
  • Improved TOML generation: The command now generates valid TOML with each configuration option as a separate field, resolving previous issues where CLI flags were incorrectly embedded in the 'run' command, leading to execution errors.
  • Refactored code and error handling: The Add struct fields were made private for consistency, and error handling was updated to use the bail!() macro.
  • Comprehensive documentation: Extensive long_about documentation with examples has been added for the config add command, and CLI documentation files were updated.
  • Increased test coverage: Added 14 end-to-end tests and 6 unit tests to validate the new functionality and ensure correct TOML generation.
Changelog
  • docs/cli/commands.json
    • Updated the usage string for config add to reflect the new flag-based approach.
    • Added numerous new flag definitions for daemon configuration options.
  • docs/cli/config.md
    • Updated the usage string for pitchfork config add to indicate flag support.
  • docs/cli/config/add.md
    • Updated the usage string to reflect flag support.
    • Added a detailed long_about section with multiple examples for using the config add command.
    • Documented all newly introduced flags for daemon configuration.
  • docs/cli/index.md
    • Updated the usage string for pitchfork config add in the main CLI index.
  • pitchfork.usage.kdl
    • Added a comprehensive long_help message for the config add command, including usage examples.
    • Defined new flags for various daemon configuration parameters such as run, retry, watch, dir, env, ready-*, depends, boot-start, on-ready, on-fail, on-retry, cron-schedule, and cron-retrigger.
  • src/cli/config/add.rs
    • Refactored the Add struct to include new fields for all daemon configuration options, making them private.
    • Implemented logic within the run method to parse and apply these new CLI flags to the PitchforkTomlDaemon configuration.
    • Added parse_retry and parse_cron_retrigger helper functions for robust input validation.
    • Updated the PitchforkToml path handling to find existing project-level configs.
    • Added unit tests for parse_retry and parse_cron_retrigger functions.
  • src/cli/config/mod.rs
    • Added #[allow(clippy::large_enum_variant)] attribute to the Commands enum.
  • src/cli/mod.rs
    • Added #[allow(clippy::large_enum_variant)] attribute to the main Commands enum.
  • tests/common/mod.rs
    • Added a new create_project_dir helper function to TestEnv for setting up test environments.
  • tests/test_e2e_config.rs
    • Added a new file containing 14 end-to-end tests for the config add command, covering various flag combinations, error handling, and TOML generation validation.
Activity
  • The pull request introduces a significant feature enhancement and bug fix for the pitchfork config add command.
  • Extensive new CLI flags have been implemented to provide granular control over daemon configuration.
  • Comprehensive unit and end-to-end tests have been added to ensure the reliability and correctness of the new functionality.
  • Documentation for the CLI has been updated to reflect the changes and provide clear usage examples.
  • The changes were co-written with Kimi K2.5 and Gemini 3.0 Pro Preview, indicating a collaborative development effort.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 25, 2026

Greptile Summary

This PR fixes a critical bug where pitchfork config add generated malformed TOML by concatenating CLI flags into the run command string. The fix adds proper CLI flag parsing for all daemon configuration options (retry, watch, env, hooks, cron, etc.) and generates correctly structured TOML with each option as a separate field.

Key changes:

  • Added 20+ CLI flags matching all daemon config fields from PitchforkTomlDaemon
  • Fixed run command generation to use either --run flag or positional args via shell_words::join
  • Added validation with proper error messages using bail!() macro
  • Made struct fields private (consistent with codebase patterns)
  • Added comprehensive documentation and examples in long_about
  • Created 14 e2e tests and 6 unit tests covering all new functionality
  • Added create_project_dir() helper to test common module
  • Suppressed clippy warnings for large enum variants caused by the expanded struct

The generated TOML is now valid and parseable, preventing shell execution errors like "exec: --: invalid option".

Confidence Score: 5/5

  • This PR is safe to merge with no issues found
  • The implementation is clean, well-tested, and follows established codebase patterns. The 20 comprehensive tests validate correctness, the error handling uses the standard bail!() macro, and the fix directly addresses the root cause of the reported bug.
  • No files require special attention

Important Files Changed

Filename Overview
src/cli/config/add.rs Added comprehensive CLI flags for all daemon config options, replaced string concatenation with proper struct fields, added validation and unit tests
tests/test_e2e_config.rs Added 14 comprehensive e2e tests covering all new flags, validation, and edge cases including config generation correctness
tests/common/mod.rs Added create_project_dir() helper method for test setup
src/cli/config/mod.rs Added clippy allow for large enum variant due to expanded Add struct
src/cli/mod.rs Added clippy allow for large enum variant due to expanded Add struct

Last reviewed commit: 9e66dc8

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request provides a comprehensive fix for the pitchfork config add command, correctly generating valid TOML configurations for daemon management. The introduction of dedicated CLI flags for all daemon configuration options significantly improves usability and prevents previous execution errors. The changes include robust argument parsing, enhanced error handling, improved encapsulation by making struct fields private, and extensive documentation with examples. The addition of numerous unit and end-to-end tests ensures the reliability and correctness of the new functionality. Overall, this is a well-executed and impactful set of changes that greatly enhances the pitchfork CLI experience.

@jdx jdx enabled auto-merge (squash) February 25, 2026 20:28
@benjaminwestern
Copy link
Contributor Author

@jdx you were right... BATS tests are much simpler.... should be done for you now.

@jdx jdx merged commit bd90bdf into jdx:main Feb 25, 2026
4 checks passed
@jdx jdx mentioned this pull request Feb 25, 2026
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