-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathplugins.go
More file actions
62 lines (49 loc) · 1.72 KB
/
plugins.go
File metadata and controls
62 lines (49 loc) · 1.72 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package parser
import (
"github.com/drycc/workflow-cli/internal/commands"
"github.com/drycc/workflow-cli/internal/plugins"
"github.com/drycc/workflow-cli/pkg/i18n"
"github.com/spf13/cobra"
)
// NewPluginsCommand creates a command for managing plugins
func NewPluginsCommand(cmdr *commands.DryccCmd) *cobra.Command {
cmd := &cobra.Command{
Use: "plugins",
Short: i18n.T("Provides utilities for interacting with plugins"),
Long: i18n.T(`Provides utilities for interacting with plugins.
Plugins provide extended functionality that is not part of the major command-line distribution.
The easiest way to use plugins is to place executables named 'drycc-<name>' in your PATH.
When you run 'drycc <name>', the CLI will automatically invoke the 'drycc-<name>' plugin if it exists.`),
Example: i18n.T(` # List all available plugins
drycc plugins list`),
}
cmd.AddCommand(pluginsListCommand(cmdr))
return cmd
}
func pluginsListCommand(cmdr *commands.DryccCmd) *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Short: i18n.T("List all visible plugin executables on a user's PATH"),
Long: i18n.T(`List all available plugin files on a user's PATH.
Available plugin files are those that are:
- executable
- anywhere on the user's PATH
- begin with "drycc-"`),
Example: i18n.T(` # List all available plugins
drycc plugins list`),
RunE: func(_ *cobra.Command, _ []string) error {
plugins := plugins.ListPlugins()
if len(plugins) == 0 {
cmdr.Println("Unable to find any drycc plugins in your PATH")
return nil
}
cmdr.Println("The following compatible plugins are available:")
cmdr.Println()
for _, plugin := range plugins {
cmdr.Println(plugin.Path)
}
return nil
},
}
return cmd
}