Skip to content

Commit

Permalink
(#33) support cheats
Browse files Browse the repository at this point in the history
Signed-off-by: R.I.Pienaar <[email protected]>
  • Loading branch information
ripienaar committed Apr 25, 2023
1 parent e59fcd9 commit 889d439
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (a *Application) introspectModel() *ApplicationModel {

var nc []*CmdModel
for _, cmd := range model.Commands {
if cmd.Name == "help" {
if cmd.Name == "help" || cmd.Name == "cheat" {
continue
}
nc = append(nc, cmd)
Expand Down Expand Up @@ -129,6 +129,7 @@ func (c *CmdClause) addCommandsFromModel(model *CmdGroupModel) {
cm.helpLong = cmd.HelpLong
cm.hidden = cmd.Hidden
cm.isDefault = cmd.Default

cm.addArgsFromModel(cmd.ArgGroupModel)
cm.addFlagsFromModel(cmd.FlagGroupModel, nil)
cm.addCommandsFromModel(cmd.CmdGroupModel)
Expand Down Expand Up @@ -209,6 +210,16 @@ func (a *Application) registerPluginModel(command string, model *ApplicationMode
globalFlags: a.flagGroup,
}

for k, v := range model.Cheats {
_, ok := a.cheats[k]
if ok {
continue
}

a.cheats[k] = v
a.cheatTags = append(a.cheatTags, k)
}

cmd.addArgsFromModel(model.ArgGroupModel)
cmd.addFlagsFromModel(model.FlagGroupModel, a.Model().FlagGroupModel)
cmd.addCommandsFromModel(model.CmdGroupModel)
Expand Down

0 comments on commit 889d439

Please sign in to comment.