Skip to content

Commit

Permalink
fix: improve cli flags and add -c config flag
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Oct 20, 2020
1 parent 8e64202 commit bf3be84
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 30 deletions.
10 changes: 1 addition & 9 deletions cmd/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ func init() {
clientsCmd.PersistentFlags().Duration("fail-after", time.Minute, `Stop retrying after the specified duration`)
clientsCmd.PersistentFlags().String("access-token", os.Getenv("OAUTH2_ACCESS_TOKEN"), "Set an access token to be used in the Authorization header, defaults to environment variable OAUTH2_ACCESS_TOKEN")
clientsCmd.PersistentFlags().String("endpoint", os.Getenv("HYDRA_ADMIN_URL"), "Set the URL where ORY Hydra is hosted, defaults to environment variable HYDRA_ADMIN_URL. A unix socket can be set in the form unix:///path/to/socket")
clientsCmd.PersistentFlags().Bool("skip-tls-verify", false, "Foolishly accept TLS certificates signed by unknown certificate authorities")

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// clientsCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// clientsCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
12 changes: 1 addition & 11 deletions cmd/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,5 @@ func init() {
keysCmd.PersistentFlags().Duration("fail-after", time.Minute, `Stop retrying after the specified duration`)
keysCmd.PersistentFlags().String("access-token", os.Getenv("OAUTH2_ACCESS_TOKEN"), "Set an access token to be used in the Authorization header, defaults to environment variable OAUTH2_ACCESS_TOKEN")
keysCmd.PersistentFlags().String("endpoint", os.Getenv("HYDRA_ADMIN_URL"), "Set the URL where ORY Hydra is hosted, defaults to environment variable HYDRA_ADMIN_URL")

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// keysCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// keysCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")

keysCmd.PersistentFlags().Bool("skip-tls-verify", false, "Foolishly accept TLS certificates signed by unknown certificate authorities")
}
2 changes: 2 additions & 0 deletions cmd/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ var migrateCmd = &cobra.Command{

func init() {
RootCmd.AddCommand(migrateCmd)

migrateCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "","Config file (default is $HOME/hydra.yaml)")
}
3 changes: 0 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ func Execute() {

func init() {
cobra.OnInitialize(initConfig)

RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "Config file (default is $HOME/.hydra.yaml)")
RootCmd.PersistentFlags().Bool("skip-tls-verify", false, "Foolishly accept TLS certificates signed by unkown certificate authorities")
}

// initConfig reads in config file and ENV variables if set.
Expand Down
8 changes: 1 addition & 7 deletions cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,8 @@ All sub-commands share command line flags and configuration options.
func init() {
RootCmd.AddCommand(serveCmd)

// Here you will define your flags and configuration settings.
serveCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "","Config file (default is $HOME/hydra.yaml)")

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// serveCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
serveCmd.PersistentFlags().Bool("dangerous-force-http", false, "DO NOT USE THIS IN PRODUCTION - Disables HTTP/2 over TLS (HTTPS) and serves HTTP instead")
serveCmd.PersistentFlags().StringSlice("dangerous-allow-insecure-redirect-urls", []string{}, "DO NOT USE THIS IN PRODUCTION - Disable HTTPS enforcement for the provided redirect URLs")

Expand Down
1 change: 1 addition & 0 deletions cmd/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ func init() {
//tokenCmd.PersistentFlags().Bool("dry", false, "do not execute the command but show the corresponding curl command instead")
tokenCmd.PersistentFlags().Duration("fail-after", time.Minute, `Stop retrying after the specified duration`)
tokenCmd.PersistentFlags().Bool("fake-tls-termination", false, `fake tls termination by adding "X-Forwarded-Proto: https" to http headers`)
tokenCmd.PersistentFlags().Bool("skip-tls-verify", false, "Foolishly accept TLS certificates signed by unknown certificate authorities")
}

0 comments on commit bf3be84

Please sign in to comment.