add machine list command and corresponding RPC endpoint

This commit is contained in:
Pavel Sviderski
2024-09-12 14:52:07 +10:00
parent 47073f017f
commit 4e042be7b7
10 changed files with 521 additions and 188 deletions
+24
View File
@@ -0,0 +1,24 @@
package machine
import (
"github.com/spf13/cobra"
"uncloud/internal/cli"
)
func NewListCommand() *cobra.Command {
opts := addOptions{}
cmd := &cobra.Command{
Use: "list",
Aliases: []string{"ls"},
Short: "List machines in a cluster",
RunE: func(cmd *cobra.Command, args []string) error {
uncli := cmd.Context().Value("cli").(*cli.CLI)
return uncli.ListMachines(cmd.Context(), opts.cluster)
},
}
cmd.Flags().StringVarP(
&opts.cluster, "cluster", "c", "",
"Name of the cluster (default is the current cluster)",
)
return cmd
}
+1
View File
@@ -12,6 +12,7 @@ func NewRootCommand() *cobra.Command {
cmd.AddCommand(
NewAddCommand(),
NewInitCommand(),
NewListCommand(),
NewTokenCommand(),
)
return cmd