Skip to content

Commit

Permalink
CLI-2 Queued Processes: commands added
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewLab-lokalise committed May 20, 2020
1 parent e85da8c commit 730ded3
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
54 changes: 54 additions & 0 deletions cmd/queuedprocess.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package cmd

import (
"github.com/spf13/cobra"
)

var (
processId string
)

// queuedProcessCmd represents the queued-process command
var queuedProcessCmd = &cobra.Command{
Use: "queued-process",
Short: "Manage queued processes",
Long: "Manage queued processes. Some heavy actions are processed asynchronously. Queued processes contain current processing status and eventually, final result.",
}

// queuedProcessListCmd represents queued-process list command
var queuedProcessListCmd = &cobra.Command{
Use: "list",
Short: "Lists all queued processes for a project",
RunE: func(*cobra.Command, []string) error {
resp, err := Api.QueuedProcesses().List(projectId)
if err != nil {
return err
}
return printJson(resp)
},
}

// queuedProcessRetrieveCmd represents queued-process retrieve command
var queuedProcessRetrieveCmd = &cobra.Command{
Use: "retrieve",
Short: "Retrieve a process for a project",
RunE: func(*cobra.Command, []string) error {
resp, err := Api.QueuedProcesses().Retrieve(projectId, processId)
if err != nil {
return err
}
return printJson(resp)
},
}

func init() {
queuedProcessCmd.AddCommand(queuedProcessListCmd, queuedProcessRetrieveCmd)
rootCmd.AddCommand(queuedProcessCmd)

// general flags
flagProjectId(queuedProcessCmd, true)

// List
queuedProcessRetrieveCmd.Flags().StringVar(&processId, "process-id", "", "A unique identifier of the process (required).")
_ = queuedProcessRetrieveCmd.MarkFlagRequired("process-id")
}
1 change: 0 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ var rootCmd = &cobra.Command{
lokalise.WithRetryTimeout(viper.GetDuration("retry-timeout")),
lokalise.WithConnectionTimeout(viper.GetDuration("connection-timeout")),
lokalise.WithPageLimit(perPage),
lokalise.WithBaseURL("https://lokalise.local/api2"),
)
return err
},
Expand Down

0 comments on commit 730ded3

Please sign in to comment.