Skip to content

Commit

Permalink
Merge pull request #43 from choria-io/33.3
Browse files Browse the repository at this point in the history
(#33) allow the embedded name and help to be changed
  • Loading branch information
ripienaar authored May 9, 2023
2 parents 2fbd695 + 51b3fac commit f888a47
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,21 @@ func (a *Application) registerPluginModel(command string, model *ApplicationMode
return cmd, nil
}

// ExternalPluginCommand extends the application using a plugin and a model describing the application
func (a *Application) ExternalPluginCommand(command string, model json.RawMessage) (*CmdClause, error) {
// ExternalPluginCommand extends the application using a plugin and a model describing the application, when name or help is not an empty string it will override that from the plugin
func (a *Application) ExternalPluginCommand(command string, model json.RawMessage, name string, help string) (*CmdClause, error) {
var m ApplicationModel
err := json.Unmarshal(model, &m)
if err != nil {
return nil, err
}

if name != "" {
m.Name = name
}
if help != "" {
m.Help = help
}

if m.Name == "" {
return nil, fmt.Errorf("plugin declared no name")
}
Expand Down

0 comments on commit f888a47

Please sign in to comment.