forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interactive.go
51 lines (42 loc) · 1.04 KB
/
interactive.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
/**
* This is an example of an interactive plugin. The plugin is invoked with
* `cf interactive` after which the user is prompted to enter a word. This word is
* then echoed back to the user.
*/
package main
import (
"fmt"
"github.com/cloudfoundry/cli/plugin"
)
type Interactive struct{}
func (c *Interactive) Run(cliConnection plugin.CliConnection, args []string) {
if args[0] == "interactive" {
var Echo string
fmt.Printf("Enter word: ")
// Simple scan to wait for interactive from stdin
fmt.Scanf("%s", &Echo)
fmt.Println("Your word was:", Echo)
}
}
func (c *Interactive) GetMetadata() plugin.PluginMetadata {
return plugin.PluginMetadata{
Name: "Interactive",
Version: plugin.VersionType{
Major: 2,
Minor: 1,
Build: 0,
},
Commands: []plugin.Command{
{
Name: "interactive",
HelpText: "help text for interactive",
UsageDetails: plugin.Usage{
Usage: "interactive - prompt for input and echo to screen\n cf interactive",
},
},
},
}
}
func main() {
plugin.Start(new(Interactive))
}