-
Notifications
You must be signed in to change notification settings - Fork 5
/
add-catalog.go
41 lines (36 loc) · 1.07 KB
/
add-catalog.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
package commands
import (
"fmt"
"github.com/brooklyncentral/brooklyn-cli/api/catalog"
"github.com/brooklyncentral/brooklyn-cli/command_metadata"
"github.com/brooklyncentral/brooklyn-cli/error_handler"
"github.com/brooklyncentral/brooklyn-cli/net"
"github.com/brooklyncentral/brooklyn-cli/scope"
"github.com/codegangsta/cli"
)
type AddCatalog struct {
network *net.Network
}
func NewAddCatalog(network *net.Network) (cmd *AddCatalog) {
cmd = new(AddCatalog)
cmd.network = network
return
}
func (cmd *AddCatalog) Metadata() command_metadata.CommandMetadata {
return command_metadata.CommandMetadata{
Name: "add-catalog",
Description: "* Add a new catalog item from the supplied YAML",
Usage: "BROOKLYN_NAME add-catalog FILEPATH",
Flags: []cli.Flag{},
}
}
func (cmd *AddCatalog) Run(scope scope.Scope, c *cli.Context) {
if err := net.VerifyLoginURL(cmd.network); err != nil {
error_handler.ErrorExit(err)
}
create, err := catalog.AddCatalog(cmd.network, c.Args().First())
if nil != err {
error_handler.ErrorExit(err)
}
fmt.Println(create)
}