Skip to content

Commit

Permalink
config: make remote-name configurable (#17)
Browse files Browse the repository at this point in the history
Closes #17
  • Loading branch information
craftamap committed Sep 8, 2021
1 parent d140c7d commit b12d0ab
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var (
PersistentPreRun: func(cmd *cobra.Command, args []string) {
username := viper.GetString("username")
password := viper.GetString("password")
remoteName := viper.GetString("remote")

if _, ok := cmd.Annotations["RequiresRepository"]; ok {
bbrepo, err := bbgit.GetBitbucketRepo(remoteName)
Expand Down Expand Up @@ -86,7 +87,7 @@ func init() {
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.config/bb)")
rootCmd.PersistentFlags().StringVar(&username, "username", "", "username")
rootCmd.PersistentFlags().StringVar(&password, "password", "", "app password")
rootCmd.PersistentFlags().StringVar(&remoteName, "remote", "origin", "if you are in a repository and don't want to interact with the default origin, you can change it")
rootCmd.PersistentFlags().StringVar(&remoteName, "remote", "", "if you are in a repository and don't want to interact with the default origin, you can change it")
rootCmd.PersistentFlags().BoolVar(&logging.PrintDebugLogs, "debug", false, "enabling this flag allows debug logs to be printed")

err := viper.BindPFlag("username", rootCmd.PersistentFlags().Lookup("username"))
Expand All @@ -100,6 +101,12 @@ func init() {
return
}

err = viper.BindPFlag("remote", rootCmd.PersistentFlags().Lookup("remote"))
if err != nil {
logging.Error(err)
return
}

pr.Add(rootCmd, &globalOpts)
issue.Add(rootCmd, &globalOpts)
api.Add(rootCmd, &globalOpts)
Expand Down

0 comments on commit b12d0ab

Please sign in to comment.