Skip to content

feat: pass through extra args after -- to forge script#60

Open
solofberlin wants to merge 1 commit into
mainfrom
feat/run-passthrough-args
Open

feat: pass through extra args after -- to forge script#60
solofberlin wants to merge 1 commit into
mainfrom
feat/run-passthrough-args

Conversation

@solofberlin
Copy link
Copy Markdown
Contributor

@solofberlin solofberlin commented Mar 2, 2026

Summary

  • Support passing additional flags to the underlying forge script command via -- separator
  • Args after -- are captured by cobra, threaded through the use case layer, and appended to the forge command line

Usage

treb run DeployCounter -- --skip-simulation
treb run DeployCounter -- --gas-estimate-multiplier 200
treb run DeployCounter --dry-run -- --extra-flag value

Test plan

  • Unit tests pass (go test ./internal/...)
  • Manual: treb run <script> --dump-command -- --skip-simulation shows --skip-simulation at end of forge command
  • Manual: treb run <script> -- --skip-simulation actually passes flag to forge

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features
    • Added support for passing through additional arguments to the forge script using a -- delimiter in the CLI
    • Arguments specified after the -- separator are now forwarded to the forge command during execution

Support `treb run <script> -- --skip-simulation` and similar patterns
where additional flags need to be forwarded to the underlying forge
script command.

Args after -- are captured by cobra's ArgsLenAtDash(), threaded through
RunScriptParams → RunScriptConfig → ForgeAdapter.buildArgs(), and
appended to the end of the forge command line.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e396cb and c72d1b1.

📒 Files selected for processing (4)
  • internal/adapters/forge/forge.go
  • internal/cli/run.go
  • internal/usecase/ports.go
  • internal/usecase/run_script.go

📝 Walkthrough

Walkthrough

This PR introduces support for passing additional arguments to the Forge script using a -- delimiter in the CLI. Arguments after -- are collected, validated, and propagated through the usecase layer to the adapter, which appends them to the final Forge command invocation.

Changes

Cohort / File(s) Summary
CLI Argument Parsing
internal/cli/run.go
Added passthrough argument handling: splits args at -- delimiter, validates single script reference before delimiter, collects trailing arguments, and passes them through RunScriptParams.
Domain Model
internal/usecase/run_script.go, internal/usecase/ports.go
Added PassthroughArgs field to RunScriptParams and RunScriptConfig structs; propagates passthrough args through the usecase layer.
Adapter Implementation
internal/adapters/forge/forge.go
Appends PassthroughArgs to Forge command after the -vvvv flag in buildArgs.

Sequence Diagram(s)

sequenceDiagram
    participant User as User/CLI
    participant Runner as CLI Runner
    participant UseCase as RunScript UseCase
    participant Adapter as Forge Adapter
    participant Forge as Forge Command

    User->>Runner: Run script with -- args
    activate Runner
    Runner->>Runner: Parse args, split at --
    Runner->>Runner: Validate script reference
    Note over Runner: Extract passthrough args
    Runner->>UseCase: RunScript(PassthroughArgs)
    deactivate Runner
    
    activate UseCase
    UseCase->>UseCase: Build RunScriptConfig
    Note over UseCase: Include PassthroughArgs in config
    UseCase->>Adapter: Execute with config
    deactivate UseCase
    
    activate Adapter
    Adapter->>Adapter: Build command args
    Note over Adapter: Append PassthroughArgs after -vvvv
    Adapter->>Forge: Execute command
    deactivate Adapter
    
    Forge-->>User: Command output
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • trebuchet-org/treb-cli#40: Also modifies ForgeAdapter.buildArgs in the same file, requiring coordination of argument ordering in the Forge command construction.

Poem

🐰 With dashes double-dashed, the arguments now pass through,
From CLI to usecase, the flow rings true,
To Forge they travel, appended with care,
A passthrough pipeline, elegant and fair! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and concisely summarizes the main change: adding support for passing extra arguments after -- to the forge script command.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/run-passthrough-args

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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.

1 participant