Skip to content

Commit 9a81a8e

Browse files
authored
Merge pull request #261 from dgageot/dry-run
Add a hidden dry run to `cagent run`
2 parents b9b4e42 + e6e53cd commit 9a81a8e

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

cmd/root/exec.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ func NewExecCmd() *cobra.Command {
1515
cmd.PersistentFlags().StringVar(&workingDir, "working-dir", "", "Set the working directory for the session (applies to tools and relative paths)")
1616
cmd.PersistentFlags().BoolVar(&autoApprove, "yolo", false, "Automatically approve all tool calls without prompting")
1717
cmd.PersistentFlags().StringVar(&attachmentPath, "attach", "", "Attach an image file to the message")
18+
19+
cmd.PersistentFlags().BoolVar(&dryRun, "dry-run", false, "Initialize the agent without executing anything")
20+
_ = cmd.PersistentFlags().MarkHidden("dry-run")
21+
1822
addGatewayFlags(cmd)
1923

2024
return cmd

cmd/root/run.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ var (
3939
workingDir string
4040
useTUI bool
4141
remoteAddress string
42+
dryRun bool
4243
)
4344

4445
// NewRunCmd creates a new run command
@@ -251,6 +252,11 @@ func doRunCommand(ctx context.Context, args []string, exec bool) error {
251252
} else {
252253
execArgs = append(execArgs, "Follow the default instructions")
253254
}
255+
256+
if dryRun {
257+
fmt.Println("Dry run mode enabled. Agent initialized but will not execute.")
258+
return nil
259+
}
254260
return runWithoutTUI(ctx, agentFilename, rt, sess, execArgs)
255261
}
256262

0 commit comments

Comments
 (0)