Skip to content

Commit

Permalink
cmd/internal/next: add --force flag
Browse files Browse the repository at this point in the history
savvy internal next -f will always update the internal run state.

This will allow users to pick and choose commands they want to run
within a runbook.
  • Loading branch information
joshi4 committed Aug 5, 2024
1 parent aea11a1 commit e460a57
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions cmd/internal/next.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,16 @@ var nextCmd = &cobra.Command{
os.Exit(1)
}

if state.CommandWithSetParams() != executedCommand {
fmt.Printf("%d", state.Index)
if forceNext || state.CommandWithSetParams() == executedCommand {
updated, err := nextCommand(ctx, cl)
if err != nil {
display.ErrorWithSupportCTA(err)
os.Exit(1)
}
fmt.Printf("%d", updated.Index)
return
}

updated, err := nextCommand(ctx, cl)
if err != nil {
display.ErrorWithSupportCTA(err)
os.Exit(1)
}
fmt.Printf("%d", updated.Index)
fmt.Printf("%d", state.Index)
},
}

Expand All @@ -56,9 +55,12 @@ func nextCommand(ctx context.Context, cl run.Client) (*run.State, error) {
}

var executedCommand string
var forceNext bool

func init() {
InternalCmd.AddCommand(nextCmd)

nextCmd.Flags().StringVarP(&executedCommand, "cmd", "c", "", "previously executed command")
nextCmd.Flags().BoolVarP(&forceNext, "force", "f", false, "force next command regardless of current state")

}

0 comments on commit e460a57

Please sign in to comment.