Skip to content

Commit

Permalink
chore: define flag names as constant
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Aug 31, 2023
1 parent 9eead61 commit f30e13c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
11 changes: 6 additions & 5 deletions modulegen/cmd/modules/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ var newExampleCmd = &cobra.Command{
}

func init() {
newExampleCmd.Flags().StringVarP(&exampleVar.Name, "name", "n", "", "Name of the example. Only alphabetical characters are allowed.")
newExampleCmd.Flags().StringVarP(&exampleVar.NameTitle, "title", "t", "", "(Optional) Title of the example name, used to override the name in the case of mixed casing (Mongodb -> MongoDB). Use camel-case when needed. Only alphabetical characters are allowed.")
newExampleCmd.Flags().StringVarP(&exampleVar.Image, "image", "i", "", "Fully-qualified name of the Docker image to be used by the example")
_ = newExampleCmd.MarkFlagRequired("image")
_ = newExampleCmd.MarkFlagRequired("name")
newExampleCmd.Flags().StringVarP(&exampleVar.Name, nameFlag, "n", "", "Name of the example. Only alphabetical characters are allowed.")
newExampleCmd.Flags().StringVarP(&exampleVar.NameTitle, titleFlag, "t", "", "(Optional) Title of the example name, used to override the name in the case of mixed casing (Mongodb -> MongoDB). Use camel-case when needed. Only alphabetical characters are allowed.")
newExampleCmd.Flags().StringVarP(&exampleVar.Image, imageFlag, "i", "", "Fully-qualified name of the Docker image to be used by the example")

_ = newExampleCmd.MarkFlagRequired(imageFlag)
_ = newExampleCmd.MarkFlagRequired(nameFlag)
}
7 changes: 7 additions & 0 deletions modulegen/cmd/modules/flags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package modules

const (
imageFlag = "image"
nameFlag = "name"
titleFlag = "title"
)
11 changes: 6 additions & 5 deletions modulegen/cmd/modules/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ var newModuleCmd = &cobra.Command{
}

func init() {
newModuleCmd.Flags().StringVarP(&exampleVar.Name, "name", "n", "", "Name of the module. Only alphabetical characters are allowed.")
newModuleCmd.Flags().StringVarP(&exampleVar.NameTitle, "title", "t", "", "(Optional) Title of the module name, used to override the name in the case of mixed casing (Mongodb -> MongoDB). Use camel-case when needed. Only alphabetical characters are allowed.")
newModuleCmd.Flags().StringVarP(&exampleVar.Image, "image", "i", "", "Fully-qualified name of the Docker image to be used by the module")
_ = newModuleCmd.MarkFlagRequired("image")
_ = newModuleCmd.MarkFlagRequired("name")
newModuleCmd.Flags().StringVarP(&exampleVar.Name, nameFlag, "n", "", "Name of the module. Only alphabetical characters are allowed.")
newModuleCmd.Flags().StringVarP(&exampleVar.NameTitle, titleFlag, "t", "", "(Optional) Title of the module name, used to override the name in the case of mixed casing (Mongodb -> MongoDB). Use camel-case when needed. Only alphabetical characters are allowed.")
newModuleCmd.Flags().StringVarP(&exampleVar.Image, imageFlag, "i", "", "Fully-qualified name of the Docker image to be used by the module")

_ = newModuleCmd.MarkFlagRequired(imageFlag)
_ = newModuleCmd.MarkFlagRequired(nameFlag)
}

0 comments on commit f30e13c

Please sign in to comment.