-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc8e9ee
commit e146c46
Showing
2 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package cmd | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
// setCmd represents the set command | ||
var setCmd = &cobra.Command{ | ||
Use: "set", | ||
Short: "sets config options", | ||
Long: `set is used to configure extended options and save | ||
them to the config file`, | ||
Args: func(cmd *cobra.Command, args []string) error { | ||
if len(args) > 0 { | ||
return errors.New("incorrect number of arguments") | ||
} | ||
return nil | ||
}, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
keys := []string{"team", "port"} | ||
for _, key := range keys { | ||
x, _ := cmd.Flags().GetString(key) | ||
if x != "" { | ||
viper.BindPFlag(key, cmd.Flags().Lookup(key)) | ||
viper.WriteConfigAs(config_file) | ||
println("Saved", key, "in config file") | ||
} | ||
} | ||
|
||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(setCmd) | ||
setCmd.Flags().StringP("team", "", "", "set the Team ID") | ||
setCmd.Flags().StringP("port", "", "", "set the Redirect URL Port number") | ||
} |