-
Notifications
You must be signed in to change notification settings - Fork 53
/
signature.go
33 lines (30 loc) · 929 Bytes
/
signature.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package plugins
import (
"encoding/json"
"github.com/jfrog/jfrog-cli-core/v2/plugins/components"
clientutils "github.com/jfrog/jfrog-client-go/utils"
"github.com/jfrog/jfrog-client-go/utils/log"
"github.com/urfave/cli"
)
const SignatureCommandName = "hidden-plugin-signature"
// Adds a hidden command to every built plugin.
// The command will later be used by the CLI to retrieve the plugin's signature to show in the CLI's help command.
func addHiddenPluginSignatureCommand(baseApp *cli.App) {
cmd := cli.Command{
Name: SignatureCommandName,
Hidden: true,
HideHelp: true,
Action: func(c *cli.Context) error {
signature := components.PluginSignature{
Name: baseApp.Name,
Usage: baseApp.Description,
}
content, err := json.Marshal(signature)
if err == nil {
log.Output(clientutils.IndentJson(content))
}
return err
},
}
baseApp.Commands = append(baseApp.Commands, cmd)
}