format machine command flags

This commit is contained in:
Pavel Sviderski
2024-10-31 20:07:25 +10:00
parent 5fe77c688b
commit 8a3f0032ae
4 changed files with 13 additions and 13 deletions
+3 -3
View File
@@ -36,14 +36,14 @@ func NewAddCommand() *cobra.Command {
return uncli.AddMachine(cmd.Context(), remoteMachine, opts.cluster, opts.name) return uncli.AddMachine(cmd.Context(), remoteMachine, opts.cluster, opts.name)
}, },
} }
cmd.Flags().StringVarP(&opts.name, "name", "n", "", "Assign a name to the machine") cmd.Flags().StringVarP(&opts.name, "name", "n", "", "Assign a name to the machine.")
cmd.Flags().StringVarP( cmd.Flags().StringVarP(
&opts.sshKey, "ssh-key", "i", "", &opts.sshKey, "ssh-key", "i", "",
"path to SSH private key for SSH remote login (default ~/.ssh/id_*)", "path to SSH private key for SSH remote login. (default ~/.ssh/id_*)",
) )
cmd.Flags().StringVarP( cmd.Flags().StringVarP(
&opts.cluster, "cluster", "c", "", &opts.cluster, "cluster", "c", "",
"Name of the cluster to add the machine to (default is the current cluster)", "Name of the cluster to add the machine to. (default is the current cluster)",
) )
return cmd return cmd
} }
+7 -7
View File
@@ -19,10 +19,10 @@ type initOptions struct {
func NewInitCommand() *cobra.Command { func NewInitCommand() *cobra.Command {
opts := initOptions{} opts := initOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "init [USER@HOST:PORT]", Use: "init [USER@HOST:PORT]",
Args: cobra.MaximumNArgs(1),
// TODO: include usage examples of initialising a local and remote machine.
Short: "Initialise a new cluster that consists of the local or remote machine.", Short: "Initialise a new cluster that consists of the local or remote machine.",
// TODO: include usage examples of initialising a local and remote machine.
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
uncli := cmd.Context().Value("cli").(*cli.CLI) uncli := cmd.Context().Value("cli").(*cli.CLI)
@@ -47,18 +47,18 @@ func NewInitCommand() *cobra.Command {
return uncli.InitCluster(cmd.Context(), remoteMachine, opts.cluster, opts.name, netPrefix) return uncli.InitCluster(cmd.Context(), remoteMachine, opts.cluster, opts.name, netPrefix)
}, },
} }
cmd.Flags().StringVarP(&opts.name, "name", "n", "", "Assign a name to the machine") cmd.Flags().StringVarP(&opts.name, "name", "n", "", "Assign a name to the machine.")
cmd.Flags().StringVar( cmd.Flags().StringVar(
&opts.network, "network", network.DefaultNetwork.String(), &opts.network, "network", network.DefaultNetwork.String(),
"IPv4 network CIDR to use for machines and services", "IPv4 network CIDR to use for machines and services.",
) )
cmd.Flags().StringVarP( cmd.Flags().StringVarP(
&opts.sshKey, "ssh-key", "i", "", &opts.sshKey, "ssh-key", "i", "",
"path to SSH private key for SSH remote login (default ~/.ssh/id_*)", "path to SSH private key for SSH remote login. (default ~/.ssh/id_*)",
) )
cmd.Flags().StringVarP( cmd.Flags().StringVarP(
&opts.cluster, "cluster", "c", "", &opts.cluster, "cluster", "c", "",
"Name of the cluster in the local config if initialising a remote machine", "Name of the cluster in the local config if initialising a remote machine.",
) )
return cmd return cmd
+2 -2
View File
@@ -10,7 +10,7 @@ func NewListCommand() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "ls", Use: "ls",
Aliases: []string{"list"}, Aliases: []string{"list"},
Short: "List machines in a cluster", Short: "List machines in a cluster.",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
uncli := cmd.Context().Value("cli").(*cli.CLI) uncli := cmd.Context().Value("cli").(*cli.CLI)
return uncli.ListMachines(cmd.Context(), cluster) return uncli.ListMachines(cmd.Context(), cluster)
@@ -18,7 +18,7 @@ func NewListCommand() *cobra.Command {
} }
cmd.Flags().StringVarP( cmd.Flags().StringVarP(
&cluster, "cluster", "c", "", &cluster, "cluster", "c", "",
"Name of the cluster (default is the current cluster)", "Name of the cluster. (default is the current cluster)",
) )
return cmd return cmd
} }
+1 -1
View File
@@ -31,7 +31,7 @@ func NewTokenCommand() *cobra.Command {
} }
cmd.Flags().StringVarP(&opts.dataDir, "data-dir", "d", machine.DefaultDataDir, cmd.Flags().StringVarP(&opts.dataDir, "data-dir", "d", machine.DefaultDataDir,
"Directory for storing persistent machine state") "Directory for storing persistent machine state.")
_ = cmd.MarkFlagDirname("data-dir") _ = cmd.MarkFlagDirname("data-dir")
return cmd return cmd