Skip to content

Commit

Permalink
cmd/connect: allow passing values as flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeneas Rekkas (arekkas) committed Dec 4, 2016
1 parent ce65b10 commit 3b0b943
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions cmd/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,25 @@ var connectCmd = &cobra.Command{
secret := "*********"
fmt.Println("To keep the current value, press enter.")

if u := input("Cluster URL [" + c.ClusterURL + "]: "); u != "" {
if u, _ := cmd.Flags().GetString("url"); u != "" {
c.ClusterURL = u
} else if u := input("Cluster URL [" + c.ClusterURL + "]: "); u != "" {
c.ClusterURL = u
}
if u := input("Client ID [" + c.ClientID + "]: "); u != "" {

if u, _ := cmd.Flags().GetString("id"); u != "" {
c.ClientID = u
} else if u := input("Client ID [" + c.ClientID + "]: "); u != "" {
c.ClientID = u
}

if c.ClientSecret == "" {
secret = "empty"
}
if u := input("Client Secret [" + secret + "]: "); u != "" {

if u, _ := cmd.Flags().GetString("secret"); u != "" {
c.ClientSecret = u
} else if u := input("Client Secret [" + secret + "]: "); u != "" {
c.ClientSecret = u
}
if err := c.Persist(); err != nil {
Expand All @@ -49,4 +58,7 @@ func input(message string) string {

func init() {
RootCmd.AddCommand(connectCmd)
connectCmd.Flags().String("url", "", "The cluster URL.")
connectCmd.Flags().String("id", "", "The client id.")
connectCmd.Flags().String("secret", "", "The client secret. Be aware that the secret will be leaked to bash history and ~/.hydra.yml")
}

0 comments on commit 3b0b943

Please sign in to comment.