-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Framework flag shell completion #80
Framework flag shell completion #80
Conversation
…e all instances that are passed are a valid state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm! I'm guessing u still need to run the completion command and add the completion script?
rootCmd.AddCommand(createCmd) | ||
|
||
createCmd.Flags().StringP("name", "n", "", "Name of project to create") | ||
createCmd.Flags().StringP("framework", "f", "", fmt.Sprintf("Framework to use. Allowed values: %s", strings.Join(allowedProjectTypes, ", "))) | ||
createCmd.Flags().VarP(&frameworkFlag, "framework", "f", fmt.Sprintf("Framework to use. Allowed values: %s", strings.Join(frameworks.AllowedProjectTypes, ", "))) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
cmd/create.go
Outdated
@@ -62,16 +68,16 @@ var createCmd = &cobra.Command{ | |||
flagFramework := cmd.Flag("framework").Value.String() | |||
|
|||
if flagFramework != "" { | |||
isValid := isValidProjectType(flagFramework, allowedProjectTypes) | |||
isValid := isValidProjectType(flagFramework, frameworks.AllowedProjectTypes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed I believe, a Var flag will automatically error if it's not in the enum!
@@ -38,7 +38,7 @@ func InitSteps(options *Options) *Steps { | |||
StepName: "Go Project Framework", | |||
Options: []Item{ | |||
{ | |||
Title: "Standard library", | |||
Title: "Standard-library", |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Yes, you need to register the flag for the completion generation with a function that gets called for the option but that's a simple one line function. cc @basokant |
This is awesome! I thought you would have to add the shell completion script that's generated from 'go-blueprint completion', but this is way better! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this could be out of scope for Go-blueprint because modifying dot files seems to be a little much for this CLI tool.
Personally, I wouldnt want something I installed just for spinning up Go boiler plate to touch my dot files.
I think certain users can have a poor experience with that.
Resolves #61
This pr adds shell completion for the --framework flag. This feature should
help users with discovering framework options, prevent typos and last but not
leas, typing less.
Besides the tab completion it also replaces the
string
types for theFrameworkType
with a type aliasFramework
. TheVarP
function registersa flag that always returns a valid string which then gets turned into a specific
type to make it type safe.
cc @basokant