|
1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package repl
-
- import "github.com/spf13/cobra"
-
- func init() {
- ttCmd := &cobra.Command{
- Use: "ticktock",
- Short: "ticktock command",
- }
- RootCmd.AddCommand(ttCmd)
-
- lsCmd := &cobra.Command{
- Use: "ls",
- Short: "list all jobs",
- Run: func(cmd *cobra.Command, args []string) {
- tickTockLs(GetCmdCtx(cmd))
- },
- }
- ttCmd.AddCommand(lsCmd)
-
- runCmd := &cobra.Command{
- Use: "run [jobName]",
- Short: "run job now",
- Args: cobra.ExactArgs(1),
- Run: func(cmd *cobra.Command, args []string) {
- tickTockRun(GetCmdCtx(cmd), args[0])
- },
- }
- ttCmd.AddCommand(runCmd)
- }
-
- func tickTockLs(ctx *CommandContext) {
- names := ctx.repl.tktk.GetJobNames()
- for _, name := range names {
- println(name)
- }
- }
-
- func tickTockRun(ctx *CommandContext, jobName string) {
- ctx.repl.tktk.RunNow(jobName)
- }
|