Released v1
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"git.franklin.lab/steve.cliff/pcli/output"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var projectCmd = &cobra.Command{
|
||||
Use: "project",
|
||||
Short: "Manage projects",
|
||||
Long: "Commands for managing Planka projects",
|
||||
}
|
||||
|
||||
var projectListCmd = &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List all projects",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
projects, err := getClient().ListProjects(getContext())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return output.Print(projects, getFormat(), os.Stdout)
|
||||
},
|
||||
}
|
||||
|
||||
var projectGetCmd = &cobra.Command{
|
||||
Use: "get <id>",
|
||||
Short: "Get a project by ID",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
project, err := getClient().GetProject(getContext(), args[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return output.Print(project, getFormat(), os.Stdout)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(projectCmd)
|
||||
projectCmd.AddCommand(projectListCmd)
|
||||
projectCmd.AddCommand(projectGetCmd)
|
||||
}
|
||||
Reference in New Issue
Block a user