Skip to content

Commit

Permalink
select first context when there is only one (#28)
Browse files Browse the repository at this point in the history
Signed-off-by: l1b0k <libokang.dev@gmail.com>
  • Loading branch information
l1b0k committed Jan 4, 2021
1 parent 25a00c0 commit af34722
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ func (ac *AddCommand) runAdd(cmd *cobra.Command, args []string) error {
return err
}
outConfig := appendConfig(oldConfig, newConfig)
if len(outConfig.Contexts) == 1 {
for k := range outConfig.Contexts {
outConfig.CurrentContext = k
}
}
cover := BoolUI(fmt.Sprintf("Are you sure you want to add 「%s」 to the 「%s」context?", newName, cfgFile))
confirm, err := strconv.ParseBool(cover)
if err != nil {
Expand Down

0 comments on commit af34722

Please sign in to comment.