Name: "server-path, sp",
Usage: "project server path (only used with pathmap type)",
},
+ cli.BoolFlag{
+ Name: "short, s",
+ Usage: "short output, only print create project id (useful from scripting)",
+ },
cli.StringFlag{
Name: "type, t",
- Usage: "project type (pathmap|pm, cloudsync|sc)",
+ Usage: "project type (pathmap|pm, cloudsync|cs)",
},
},
},
{
Name: "get",
- Usage: "Get a property of a project",
+ Usage: "Get properties of a project",
Action: projectsGet,
Flags: []cli.Flag{
cli.StringFlag{
func projectsAdd(ctx *cli.Context) error {
// Decode project type
- var ptype xaapiv1.ProjectType
+ var pType xaapiv1.ProjectType
switch strings.ToLower(ctx.String("type")) {
case "pathmap", "pm":
- ptype = xaapiv1.TypePathMap
+ pType = xaapiv1.TypePathMap
case "cloudsync", "cs":
- ptype = xaapiv1.TypeCloudSync
+ pType = xaapiv1.TypeCloudSync
default:
return cli.NewExitError("Unknown project type", 1)
}
prj := xaapiv1.ProjectConfig{
ServerID: XdsServerIDGet(),
Label: ctx.String("label"),
- Type: ptype,
+ Type: pType,
ClientPath: ctx.String("path"),
ServerPath: ctx.String("server-path"),
}
return cli.NewExitError(err, 1)
}
- fmt.Printf("New project '%s' (id %v) successfully created.\n", newPrj.Label, newPrj.ID)
+ if ctx.Bool("short") {
+ fmt.Println(newPrj.ID)
+ } else {
+ fmt.Printf("New project '%s' (id %v) successfully created.\n", newPrj.Label, newPrj.ID)
+ }
return nil
}