-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorg_space.go
More file actions
42 lines (33 loc) · 993 Bytes
/
org_space.go
File metadata and controls
42 lines (33 loc) · 993 Bytes
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
package main
import (
"fmt"
"github.com/cloudfoundry/cli/plugin"
)
type OrgSpace struct{}
func (c *OrgSpace) GetMetadata() plugin.PluginMetadata {
return plugin.PluginMetadata{
Name: "OrgSpace",
Commands: []plugin.Command{
{
Name: "org-space",
HelpText: "Command to call cli command. It passes all arguments through to the command",
},
},
}
}
func main() {
plugin.Start(new(OrgSpace))
}
func (c *OrgSpace) Run(cliConnection plugin.CliConnection, args []string) {
if len(args) != 3 {
fmt.Print("You must provide an org and space i.e. org-space org space")
return
}
orgName := args[1]
spaceName := args[2]
cliConnection.CliCommandWithoutTerminalOutput("create-org", orgName)
cliConnection.CliCommandWithoutTerminalOutput("create-space", spaceName, "-o", orgName)
cliConnection.CliCommandWithoutTerminalOutput("target", "-o", orgName, "-s", spaceName)
fmt.Printf("Org %s and Space %s is now available and targeted", orgName, spaceName)
return
}