Skip to content
Merged
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
31 changes: 31 additions & 0 deletions cmd/skpr/cron/command.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package cron

import (
"github.com/spf13/cobra"

"github.com/skpr/cli/cmd/skpr/cron/job"
"github.com/skpr/cli/cmd/skpr/cron/list"
"github.com/skpr/cli/cmd/skpr/cron/resume"
"github.com/skpr/cli/cmd/skpr/cron/suspend"
)

var (
cmdLong = `Cron operations.`
)

// NewCommand creates a new cobra.Command for 'config' sub command
func NewCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "cron",
DisableFlagsInUseLine: true,
Short: "Cron operations.",
Long: cmdLong,
}

cmd.AddCommand(job.NewCommand())
cmd.AddCommand(list.NewCommand())
cmd.AddCommand(resume.NewCommand())
cmd.AddCommand(suspend.NewCommand())

return cmd
}
25 changes: 25 additions & 0 deletions cmd/skpr/cron/job/command.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package job

import (
"github.com/spf13/cobra"

"github.com/skpr/cli/cmd/skpr/cron/job/list"
)

var (
cmdLong = `Job operations.`
)

// NewCommand creates a new cobra.Command for 'config' sub command
func NewCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "job",
DisableFlagsInUseLine: true,
Short: "Job operations.",
Long: cmdLong,
}

cmd.AddCommand(list.NewCommand())

return cmd
}
30 changes: 30 additions & 0 deletions cmd/skpr/cron/job/list/command.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package list

import (
"github.com/spf13/cobra"

"github.com/skpr/cli/internal/command/cron/job/list"
)

var (
cmdLong = `List all the jobs that have been executed as part of cron.`
)

// NewCommand creates a new cobra.Command for 'delete' sub command
func NewCommand() *cobra.Command {
command := list.Command{}

cmd := &cobra.Command{
Use: "list <environment>",
Args: cobra.ExactArgs(1),
DisableFlagsInUseLine: true,
Short: "List all jobs associated with an environment.",
Long: cmdLong,
RunE: func(cmd *cobra.Command, args []string) error {
command.Environment = args[0]
return command.Run(cmd.Context())
},
}

return cmd
}
30 changes: 30 additions & 0 deletions cmd/skpr/cron/list/command.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package list

import (
"github.com/spf13/cobra"

"github.com/skpr/cli/internal/command/cron/list"
)

var (
cmdLong = `List all the cron jobs for a given environment.`
)

// NewCommand creates a new cobra.Command for 'delete' sub command
func NewCommand() *cobra.Command {
command := list.Command{}

cmd := &cobra.Command{
Use: "list <environment>",
Args: cobra.ExactArgs(1),
DisableFlagsInUseLine: true,
Short: "List all Crons associated with an environment.",
Long: cmdLong,
RunE: func(cmd *cobra.Command, args []string) error {
command.Environment = args[0]
return command.Run(cmd.Context())
},
}

return cmd
}
30 changes: 30 additions & 0 deletions cmd/skpr/cron/resume/command.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package resume

import (
"github.com/spf13/cobra"

"github.com/skpr/cli/internal/command/cron/resume"
)

var (
cmdLong = `Resume all cron jobs for a given environment.`
)

// NewCommand creates a new cobra.Command for 'delete' sub command
func NewCommand() *cobra.Command {
command := resume.Command{}

cmd := &cobra.Command{
Use: "resume <environment>",
Args: cobra.ExactArgs(1),
DisableFlagsInUseLine: true,
Short: "Resume all cron jobs associated with an environment.",
Long: cmdLong,
RunE: func(cmd *cobra.Command, args []string) error {
command.Environment = args[0]
return command.Run(cmd.Context())
},
}

return cmd
}
33 changes: 33 additions & 0 deletions cmd/skpr/cron/suspend/command.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package suspend

import (
"github.com/spf13/cobra"

"github.com/skpr/cli/internal/command/cron/suspend"
)

var (
cmdLong = `Suspend all cron jobs for a given environment.`
)

// NewCommand creates a new cobra.Command for 'delete' sub command
func NewCommand() *cobra.Command {
command := suspend.Command{}

cmd := &cobra.Command{
Use: "suspend <environment>",
Args: cobra.ExactArgs(1),
DisableFlagsInUseLine: true,
Short: "Suspend all cron jobs associated with an environment.",
Long: cmdLong,
RunE: func(cmd *cobra.Command, args []string) error {
command.Environment = args[0]
return command.Run(cmd.Context())
},
}

cmd.Flags().BoolVarP(&command.Wait, "wait", "w", command.Wait, "Wait for running cron tasks to complete")
cmd.Flags().DurationVarP(&command.Timeout, "timeout", "t", command.Timeout, "Allowed timeout threshold when waiting for cron tasks")

return cmd
}
2 changes: 2 additions & 0 deletions cmd/skpr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/skpr/cli/cmd/skpr/backup"
"github.com/skpr/cli/cmd/skpr/config"
"github.com/skpr/cli/cmd/skpr/create"
"github.com/skpr/cli/cmd/skpr/cron"
deletecmd "github.com/skpr/cli/cmd/skpr/delete"
"github.com/skpr/cli/cmd/skpr/deploy"
"github.com/skpr/cli/cmd/skpr/exec"
Expand Down Expand Up @@ -63,6 +64,7 @@ func main() {
cmd.AddCommand(backup.NewCommand())
cmd.AddCommand(config.NewCommand())
cmd.AddCommand(create.NewCommand())
cmd.AddCommand(cron.NewCommand())
cmd.AddCommand(deletecmd.NewCommand())
cmd.AddCommand(deploy.NewCommand())
cmd.AddCommand(exec.NewCommand())
Expand Down