forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_2.go
52 lines (43 loc) · 986 Bytes
/
test_2.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* 1. Setup the server so cf can call it under main.
e.g. `cf my-plugin` creates the callable server. now we can call the Run command
* 2. Implement Run that is the actual code of the plugin!
* 3. Return an error
**/
package main
import (
"fmt"
"github.com/cloudfoundry/cli/plugin"
)
type Test2 struct{}
func (c *Test2) Run(cliConnection plugin.CliConnection, args []string) {
if args[0] == "test_2_cmd1" {
theFirstCmd()
} else if args[0] == "test_2_cmd2" {
theSecondCmd()
}
}
func (c *Test2) GetMetadata() plugin.PluginMetadata {
return plugin.PluginMetadata{
Name: "Test2",
Commands: []plugin.Command{
{
Name: "test_2_cmd1",
HelpText: "help text for test_2_cmd1",
},
{
Name: "test_2_cmd2",
HelpText: "help text for test_2_cmd2",
},
},
}
}
func theFirstCmd() {
fmt.Println("You called cmd1 in test_2")
}
func theSecondCmd() {
fmt.Println("You called cmd2 in test_2")
}
func main() {
plugin.Start(new(Test2))
}