Skip to content

Commit

Permalink
Recommit correct configuration file load
Browse files Browse the repository at this point in the history
  • Loading branch information
maxlandon committed May 15, 2023
1 parent fc9b8c3 commit 47d0a68
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions complete.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ func Complete(cmd *cobra.Command, args []string, onFinalize func()) (common.RawV
// action, current := generate(cmd, args)
action, context := traverse(cmd, args[2:])

if err := config.Load(); err != nil {
action = ActionMessage("failed to load config: " + err.Error())
}

invoked := action.Invoke(context)

// And adapt/fetch the results from invoked action
Expand Down
2 changes: 0 additions & 2 deletions internal/shell/spec/snippet.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func command(cmd *cobra.Command) Command {
}
f := pflagfork.Flag{Flag: flag}
c.Flags[f.Definition()] = f.Usage

})

cmd.PersistentFlags().VisitAll(func(flag *pflag.Flag) {
Expand All @@ -40,7 +39,6 @@ func command(cmd *cobra.Command) Command {
}
f := pflagfork.Flag{Flag: flag}
c.PersistentFlags[f.Definition()] = f.Usage

})

for _, subcmd := range cmd.Commands() {
Expand Down
16 changes: 15 additions & 1 deletion internalActions.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ func actionFlags(cmd *cobra.Command) Action {
flagSet := pflagfork.FlagSet{FlagSet: cmd.Flags()}
isShorthandSeries := flagSet.IsShorthandSeries(c.Value)

needsMultipart := false

vals := make([]string, 0)
flagSet.VisitAll(func(f *pflagfork.Flag) {
switch {
Expand Down Expand Up @@ -104,13 +106,25 @@ func actionFlags(cmd *cobra.Command) Action {
if f.Shorthand != "" && f.ShorthandDeprecated == "" {
vals = append(vals, "-"+f.Shorthand, f.Usage, f.Style())
}

if strings.Contains(f.Name, ".") {
needsMultipart = true
}
}
})

if isShorthandSeries {
return ActionStyledValuesDescribed(vals...).Prefix(c.Value).NoSpace('*')
}
return ActionStyledValuesDescribed(vals...).MultiParts(".") // multiparts completion for flags grouped with `.`

action := ActionStyledValuesDescribed(vals...)

// multiparts completion for flags grouped with `.`
if needsMultipart {
action = action.MultiParts(".")
}

return action
}).Tag("flags")
}

Expand Down

0 comments on commit 47d0a68

Please sign in to comment.