Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions internal/adapters/forge/forge.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,9 @@ func (f *ForgeAdapter) buildArgs(config usecase.RunScriptConfig) []string {
}
args = append(args, "-vvvv")

// Passthrough args from CLI (after --)
args = append(args, config.PassthroughArgs...)

return args
}

Expand Down
43 changes: 34 additions & 9 deletions internal/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,36 @@ Examples:
treb run script/deploy/DeployCounter.s.sol --debug

# Run with specific network and profile
treb run script/deploy/DeployCounter.s.sol --network sepolia --profile production`,
Args: cobra.ExactArgs(1),
treb run script/deploy/DeployCounter.s.sol --network sepolia --profile production

# Pass extra flags to forge script (after --)
treb run script/deploy/DeployCounter.s.sol -- --skip-simulation
treb run script/deploy/DeployCounter.s.sol -- --gas-estimate-multiplier 200`,
Args: func(cmd *cobra.Command, args []string) error {
// Require at least 1 arg (script ref). Additional args after -- are passthrough.
dashIdx := cmd.ArgsLenAtDash()
if dashIdx == 0 {
return fmt.Errorf("requires a script reference argument before --")
}
positional := args
if dashIdx > 0 {
positional = args[:dashIdx]
}
if len(positional) != 1 {
return fmt.Errorf("accepts 1 arg(s), received %d", len(positional))
}
return nil
},
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
// Get app from context (v2 usecase wiring)
// Split positional args from passthrough args (after --)
deploymentScriptRef := args[0]
var passthroughArgs []string
if dashIdx := cmd.ArgsLenAtDash(); dashIdx >= 0 {
passthroughArgs = args[dashIdx:]
}

// Get app from context (v2 usecase wiring)
app, err := getApp(cmd)
if err != nil {
return err
Expand All @@ -86,12 +110,13 @@ Examples:
}

params := usecase.RunScriptParams{
ScriptRef: deploymentScriptRef,
Parameters: parsedEnvVars,
DryRun: dryRun,
Debug: debug,
DebugJSON: debugJSON,
DumpCommand: dumpCmd,
ScriptRef: deploymentScriptRef,
Parameters: parsedEnvVars,
DryRun: dryRun,
Debug: debug,
DebugJSON: debugJSON,
DumpCommand: dumpCmd,
PassthroughArgs: passthroughArgs,
}
result, err := app.RunScript.Run(cmd.Context(), params)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions internal/usecase/ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ type RunScriptConfig struct {
SenderScriptConfig config.SenderScriptConfig
Progress ProgressSink
ForkEnvOverrides map[string]string // env var overrides for fork mode (e.g. NETWORK_RPC_URL=http://localhost:PORT)
PassthroughArgs []string // Additional args passed through to forge script (after --)
}

// RunResultHydrator hydrated RunResults with domain models.
Expand Down
18 changes: 10 additions & 8 deletions internal/usecase/run_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import (

// RunScriptParams contains parameters for running a script
type RunScriptParams struct {
ScriptRef string
Parameters map[string]string
DryRun bool
Debug bool
DebugJSON bool
Verbose bool
NonInteractive bool
DumpCommand bool
ScriptRef string
Parameters map[string]string
DryRun bool
Debug bool
DebugJSON bool
Verbose bool
NonInteractive bool
DumpCommand bool
PassthroughArgs []string // Additional args passed through to forge script (after --)
}

// RunScriptResult contains the result of running a script
Expand Down Expand Up @@ -185,6 +186,7 @@ func (uc *RunScript) Run(ctx context.Context, params RunScriptParams) (*RunScrip
SenderScriptConfig: *senderScriptConfig,
Slow: uc.config.Slow,
ForkEnvOverrides: forkEnvOverrides,
PassthroughArgs: params.PassthroughArgs,
}

// Fork mode pre-run checks: health check + snapshot
Expand Down