-
Notifications
You must be signed in to change notification settings - Fork 1
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
sc-235696/add viper #8
Conversation
This pull request has been linked to Shortcut Story #235696: create command to list existing projects. |
fmt.Fprintf(cmd.OutOrStdout(), "{\"hello\": \"world\"}") | ||
}, | ||
} | ||
func newHelloCmd() *cobra.Command { |
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 we're going to want this pattern to eventually pass in dependencies. I'd like to move away from a global viper
variable since it's implicit state, but it's easier to leave it as-is for now.
} | ||
|
||
// bind command-specific flags | ||
cmd.Flags().BoolP("informal", "i", false, "Make the greeting less formal") |
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.
We can keep the command-specific stuff in the constructor so we don't need to do this all in the root command.
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.
💯
Adds viper to control option flags. We can use it to eventually support env vars and a config file. The next step is to add the go API client that uses the
accessToken
option to make a call to get projects.Output from running
go run main.go --help
Output from running
go run main.go hello --help