cli: format UI strings as suggested by cobra

This commit is contained in:
Thomas Tendyck 2022-05-06 17:51:41 +02:00 committed by Thomas Tendyck
parent a879043f03
commit 19bd097864
7 changed files with 23 additions and 23 deletions

View File

@ -19,7 +19,7 @@ import (
func newCreateCmd() *cobra.Command { func newCreateCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "create {aws|gcp|azure}", Use: "create {aws|gcp|azure}",
Short: "Create instances on a cloud platform for your Constellation cluster.", Short: "Create instances on a cloud platform for your Constellation cluster",
Long: "Create instances on a cloud platform for your Constellation cluster.", Long: "Create instances on a cloud platform for your Constellation cluster.",
Args: cobra.MatchAll( Args: cobra.MatchAll(
cobra.ExactArgs(1), cobra.ExactArgs(1),
@ -29,13 +29,13 @@ func newCreateCmd() *cobra.Command {
ValidArgsFunction: createCompletion, ValidArgsFunction: createCompletion,
RunE: runCreate, RunE: runCreate,
} }
cmd.Flags().String("name", "constell", "Create the Constellation cluster with the specified name.") cmd.Flags().String("name", "constell", "create the Constellation cluster with the specified name")
cmd.Flags().BoolP("yes", "y", false, "Create the Constellation cluster without further confirmation.") cmd.Flags().BoolP("yes", "y", false, "create the Constellation cluster without further confirmation")
cmd.Flags().IntP("control-plane-nodes", "c", 1, "Number of control-plane nodes.") cmd.Flags().IntP("control-plane-nodes", "c", 1, "number of control-plane nodes (required)")
must(cobra.MarkFlagRequired(cmd.Flags(), "control-plane-nodes")) must(cobra.MarkFlagRequired(cmd.Flags(), "control-plane-nodes"))
cmd.Flags().IntP("worker-nodes", "w", 1, "Number of worker nodes.") cmd.Flags().IntP("worker-nodes", "w", 1, "number of worker nodes (required)")
must(cobra.MarkFlagRequired(cmd.Flags(), "worker-nodes")) must(cobra.MarkFlagRequired(cmd.Flags(), "worker-nodes"))
cmd.Flags().StringP("instance-type", "t", "", "Instance type of cluster nodes.") cmd.Flags().StringP("instance-type", "t", "", "instance type of cluster nodes")
must(cmd.RegisterFlagCompletionFunc("instance-type", instanceTypeCompletion)) must(cmd.RegisterFlagCompletionFunc("instance-type", instanceTypeCompletion))
return cmd return cmd
} }

View File

@ -34,17 +34,17 @@ import (
func newInitCmd() *cobra.Command { func newInitCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "init", Use: "init",
Short: "Initialize the Constellation cluster. Start your confidential Kubernetes.", Short: "Initialize the Constellation cluster",
Long: "Initialize the Constellation cluster. Start your confidential Kubernetes.", Long: "Initialize the Constellation cluster. Start your confidential Kubernetes.",
ValidArgsFunction: initCompletion, ValidArgsFunction: initCompletion,
Args: cobra.ExactArgs(0), Args: cobra.ExactArgs(0),
RunE: runInitialize, RunE: runInitialize,
} }
cmd.Flags().String("privatekey", "", "Path to your private key.") cmd.Flags().String("privatekey", "", "path to your private key")
cmd.Flags().String("master-secret", "", "Path to base64 encoded master secret.") cmd.Flags().String("master-secret", "", "path to base64 encoded master secret")
cmd.Flags().Bool("wg-autoconfig", false, "Enable automatic configuration of WireGuard interface.") cmd.Flags().Bool("wg-autoconfig", false, "enable automatic configuration of WireGuard interface")
must(cmd.Flags().MarkHidden("wg-autoconfig")) must(cmd.Flags().MarkHidden("wg-autoconfig"))
cmd.Flags().Bool("autoscale", false, "Enable Kubernetes cluster-autoscaler.") cmd.Flags().Bool("autoscale", false, "enable Kubernetes cluster-autoscaler")
return cmd return cmd
} }

View File

@ -24,17 +24,17 @@ var diskUUIDRegexp = regexp.MustCompile("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA
func newRecoverCmd() *cobra.Command { func newRecoverCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "recover", Use: "recover",
Short: "Recover a Constellation cluster.", Short: "Recover a Constellation cluster",
Long: "Recover a Constellation cluster by sending a recovery key to an instance in the boot stage." + Long: "Recover a Constellation cluster by sending a recovery key to an instance in the boot stage." +
"\nThis is only required if instances restart without other instances available for bootstrapping.", "\nThis is only required if instances restart without other instances available for bootstrapping.",
Args: cobra.ExactArgs(0), Args: cobra.ExactArgs(0),
RunE: runRecover, RunE: runRecover,
} }
cmd.Flags().StringP("endpoint", "e", "", "Endpoint of the instance. Form: HOST[:PORT]") cmd.Flags().StringP("endpoint", "e", "", "endpoint of the instance, passed as HOST[:PORT] (required)")
must(cmd.MarkFlagRequired("endpoint")) must(cmd.MarkFlagRequired("endpoint"))
cmd.Flags().String("disk-uuid", "", "Disk UUID of the encrypted state disk.") cmd.Flags().String("disk-uuid", "", "disk UUID of the encrypted state disk (required)")
must(cmd.MarkFlagRequired("disk-uuid")) must(cmd.MarkFlagRequired("disk-uuid"))
cmd.Flags().String("master-secret", "", "Path to base64 encoded master secret.") cmd.Flags().String("master-secret", "", "path to base64 encoded master secret")
return cmd return cmd
} }

View File

@ -11,7 +11,7 @@ import (
var rootCmd = &cobra.Command{ var rootCmd = &cobra.Command{
Use: "constellation", Use: "constellation",
Short: "Set up your Constellation cluster.", Short: "Set up your Constellation cluster",
Long: "Set up your Constellation cluster.", Long: "Set up your Constellation cluster.",
SilenceUsage: true, SilenceUsage: true,
} }
@ -54,7 +54,7 @@ func init() {
cobra.EnableCommandSorting = false cobra.EnableCommandSorting = false
// Set output of cmd.Print to stdout. (By default, it's stderr.) // Set output of cmd.Print to stdout. (By default, it's stderr.)
rootCmd.SetOut(os.Stdout) rootCmd.SetOut(os.Stdout)
rootCmd.PersistentFlags().String("dev-config", "", "Set this flag to create the Constellation cluster using settings from a development config.") rootCmd.PersistentFlags().String("dev-config", "", "create the Constellation cluster using settings from a development config")
must(rootCmd.MarkPersistentFlagFilename("dev-config", "json")) must(rootCmd.MarkPersistentFlagFilename("dev-config", "json"))
rootCmd.AddCommand(newCreateCmd()) rootCmd.AddCommand(newCreateCmd())
rootCmd.AddCommand(newInitCmd()) rootCmd.AddCommand(newInitCmd())

View File

@ -18,7 +18,7 @@ import (
func newTerminateCmd() *cobra.Command { func newTerminateCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "terminate", Use: "terminate",
Short: "Terminate an existing Constellation cluster.", Short: "Terminate an existing Constellation cluster",
Long: "Terminate an existing Constellation cluster. The cluster can't be started again, and all persistent storage will be lost.", Long: "Terminate an existing Constellation cluster. The cluster can't be started again, and all persistent storage will be lost.",
Args: cobra.NoArgs, Args: cobra.NoArgs,
RunE: runTerminate, RunE: runTerminate,

View File

@ -19,7 +19,7 @@ import (
func newVerifyCmd() *cobra.Command { func newVerifyCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "verify {aws|azure|gcp}", Use: "verify {aws|azure|gcp}",
Short: "Verify the confidential properties of your Constellation cluster.", Short: "Verify the confidential properties of your Constellation cluster",
Long: "Verify the confidential properties of your Constellation cluster.", Long: "Verify the confidential properties of your Constellation cluster.",
Args: cobra.MatchAll( Args: cobra.MatchAll(
cobra.ExactArgs(1), cobra.ExactArgs(1),
@ -28,9 +28,9 @@ func newVerifyCmd() *cobra.Command {
), ),
RunE: runVerify, RunE: runVerify,
} }
cmd.Flags().String("owner-id", "", "Verify using the owner identity derived from the master secret.") cmd.Flags().String("owner-id", "", "verify using the owner identity derived from the master secret")
cmd.Flags().String("unique-id", "", "Verify using the unique cluster identity.") cmd.Flags().String("unique-id", "", "verify using the unique cluster identity")
cmd.Flags().StringP("node-endpoint", "e", "", "Endpoint of the node to verify. Form: HOST[:PORT]") cmd.Flags().StringP("node-endpoint", "e", "", "endpoint of the node to verify, passed as HOST[:PORT] (required)")
must(cmd.MarkFlagRequired("node-endpoint")) must(cmd.MarkFlagRequired("node-endpoint"))
return cmd return cmd
} }

View File

@ -9,7 +9,7 @@ func newVersionCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "version", Use: "version",
Short: "Display version of this CLI", Short: "Display version of this CLI",
Long: `Display version of this CLI`, Long: "Display version of this CLI.",
Args: cobra.NoArgs, Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
cmd.Printf("CLI Version: v%s \n", constants.CliVersion) cmd.Printf("CLI Version: v%s \n", constants.CliVersion)