-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
103 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package internal | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/getsavvyinc/savvy-cli/display" | ||
"github.com/getsavvyinc/savvy-cli/server/run" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// currentCmd represents the current command | ||
var currentCmd = &cobra.Command{ | ||
Use: "current", | ||
Short: "Get the command to run", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
ctx := cmd.Context() | ||
cl, err := run.NewDefaultClient(ctx) | ||
if err != nil { | ||
display.ErrorWithSupportCTA(err) | ||
return | ||
} | ||
|
||
curr := cl.CurrentCommand() | ||
fmt.Printf("%s", curr) | ||
}, | ||
} | ||
|
||
func init() { | ||
InternalCmd.AddCommand(currentCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package internal | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/getsavvyinc/savvy-cli/display" | ||
"github.com/getsavvyinc/savvy-cli/server/run" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// nextCmd represents the next command | ||
var nextCmd = &cobra.Command{ | ||
Use: "next", | ||
Hidden: true, | ||
Short: "Update runbook state to next step", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
ctx := cmd.Context() | ||
cl, err := run.NewDefaultClient(ctx) | ||
if err != nil { | ||
display.ErrorWithSupportCTA(err) | ||
return | ||
} | ||
|
||
curr := cl.CurrentCommand() | ||
if curr != executedCommand { | ||
return | ||
} | ||
|
||
idx, err := cl.NextCommand() | ||
if err != nil { | ||
display.ErrorWithSupportCTA(err) | ||
return | ||
} | ||
|
||
fmt.Printf("%d", idx) | ||
}, | ||
} | ||
|
||
var executedCommand string | ||
|
||
func init() { | ||
InternalCmd.AddCommand(nextCmd) | ||
|
||
nextCmd.Flags().StringVarP(&executedCommand, "cmd", "c", "", "previously executed command") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters