WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/plugin_developer_guide.md
+39-13Lines changed: 39 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,21 +44,28 @@ IBM Cloud CLI SDK provides a set of APIs to register and manage plug-ins. It als
44
44
Build: 0,
45
45
},
46
46
MinCliVersion: plugin.VersionType{
47
-
Major: 0,
47
+
Major: 2,
48
48
Minor: 0,
49
-
Build: 1,
49
+
Build: 0,
50
50
},
51
51
52
52
PrivateEndpointSupported: true,
53
53
54
54
IsCobraPlugin: true,
55
55
56
+
Namespaces: []plugin.Namespace{
57
+
{
58
+
Name: "demo-plugin",
59
+
}
60
+
},
61
+
56
62
Commands: []plugin.Command{
57
63
{
64
+
Namespace: "demo-plugin",
58
65
Name: "echo",
59
-
Alias: "ec",
66
+
Aliases: []{"ec"},
60
67
Description: "Echo a message on terminal.",
61
-
Usage: "ibmcloud echo MESSAGE [-u]",
68
+
Usage: "ibmcloud demo-plugin echo MESSAGE [-u]",
62
69
Flags: []plugin.Flag{
63
70
{
64
71
Name: "u",
@@ -73,18 +80,37 @@ IBM Cloud CLI SDK provides a set of APIs to register and manage plug-ins. It als
73
80
```
74
81
75
82
**Understanding the fields in this `plugin.PluginMetadata`struct:**
76
-
- _Name_: The name of plug-in. It will be displayed when using `ibmcloud plugin list` command or can be used to uninstall the plug-in through `ibmcloud plugin uninstall` command.
83
+
- _Name_ (**required**): The name of plug-in. It will be displayed when using `ibmcloud plugin list` command or can be used to uninstall the plug-in through `ibmcloud plugin uninstall` command.
77
84
- It is **strongly** encouraged to use a name that best describes the service the plug-in provides.
78
-
- _Aliases_: A list of short names of the plug-in that can be used as a stand-in for installing, updating, uninstalling and using the plug-in.
85
+
- _Aliases_ (*optional*): A list of short names of the plug-in that can be used as a stand-in for installing, updating, uninstalling and using the plug-in.
79
86
- It is strongly recommended that you have at least one alias to improve the usability of the plug-in.
80
-
- _Version_: The version of plug-in.
81
-
- _MinCliVersion_: The minimal version of IBMCloudCLI required by the plug-in.
82
-
- _PrivateEndpointSupported_: Indicatesif the plug-in is designed to also be used over the private network.
83
-
- _IsCobraPlugin_: Indicatesif the plug-in is built using the Cobra framework.
87
+
- _Version_ (**required**): The version of plug-in.
88
+
- _MinCliVersion_ (**required**): The minimal version of IBMCloudCLI required by the plug-in.
89
+
- _PrivateEndpointSupported_ (*optional*): Indicatesif the plug-in is designed to also be used over the private network.
90
+
- _IsCobraPlugin_ (*optional*): Indicatesif the plug-in is built using the Cobra framework.
84
91
- It is **strongly** recommended that you use this framework to build your plug-in.
85
-
- _Commands_: The array of `plugin.Commands` to register the plug-in commands.
86
-
- _Alias_: Alias of the Alias usually is a short name of the command.
87
-
- _Command.Flags_: The command flags (options) which will be displayed as a part of help output of the command.
92
+
- _Alias_ (*optional*): An alias is a short name of the command.
93
+
- _Namespaces[]_ (**required**): The list of namespaces / categories that group commands of similar functionality. A command under a namespace is run using `ibmcloud [namespace] [command]`. Visit [1.2Namespaces](#12-namespace) for more information.
94
+
- _Namespaces[].ParentName_ (*optional*): The fully qualified name of the parent namespace
95
+
- _Namespaces[].Name_ (**required**): The base name of the namespace
96
+
- _Namespaces[].Aliases_ (*optional*): A list of aliases for the namespace
97
+
- _Namespaces[].Description_ (*optional*): The description of the namespace
98
+
- _Namespaces[].Stage_ (*optional*): The stage of the commands in the namespace
99
+
- _Commands[]_ (**required**): The array of `plugin.Commands` to register the plug-in commands. At least one command must be registered.
100
+
- _Commands[].Name_ (**required**): The name of the command
101
+
- _Commands[].Aliases[]_ (*optional*): A list of short names to be used as a stand-in for calling the command.
102
+
- _Commands[].Description_ (**required**): A short description of the command. Details on flags and arguments should be placed in **Usage** below.
103
+
- _Commands[].Usage_ (**required**): The usage text to be displayed in the command help
104
+
- _Commands[].Flags_(*optional*): The command flags (options) which will be displayed as a part of help output of the command.
105
+
- _Commands[].Flags[].Name_ (**required**): The name of the optional flag
106
+
- _Commands[].Flags[].Description_ (**required**): The description of the optional flag
107
+
- _Commands[].Flags[].HasValue_ (*optional*): True, if the optional flag requires a value (eg.`--description "foobar"`)
108
+
- _Commands[].Flags[].Hidden_ (optional): True, to hide the optional flag should be hidden in the command help
109
+
- _Commands[].Hidden_ (*optional*): True, to hide the command in the root namespace help command
110
+
- _Commands[].Stage_ (*optional*): The stage of the command
111
+
112
+
113
+
88
114
89
115
4. Add the logic of plug-in command process in `Run` method, for example:
0 commit comments