|
| 1 | +package main |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + "os" |
| 6 | + |
| 7 | + "github.com/codegangsta/cli" |
| 8 | +) |
| 9 | + |
| 10 | +func main() { |
| 11 | + app := cli.NewApp() |
| 12 | + app.Name = "trireme" |
| 13 | + app.Usage = "A control tool for Deis" |
| 14 | + app.Commands = commands() |
| 15 | + app.Run(os.Args) |
| 16 | +} |
| 17 | + |
| 18 | +func commands() []cli.Command { |
| 19 | + return []cli.Command{ |
| 20 | + { |
| 21 | + Name: "install", |
| 22 | + Usage: "Install platform components", |
| 23 | + /* |
| 24 | + Action: func(c *cli.Context) { |
| 25 | + fmt.Println("I can only install Platform right now.") |
| 26 | + }, |
| 27 | + */ |
| 28 | + Subcommands: installCommands(), |
| 29 | + }, |
| 30 | + } |
| 31 | +} |
| 32 | + |
| 33 | +func installCommands() []cli.Command { |
| 34 | + parts := map[string]string{ |
| 35 | + // In alpha order, please. |
| 36 | + "builder": "the builder", |
| 37 | + "controller": "the controller", |
| 38 | + "database": "the database", |
| 39 | + "router": "the router mesh", |
| 40 | + "store": "the store and all of its components", |
| 41 | + // FIXME: Do the rest. |
| 42 | + } |
| 43 | + |
| 44 | + // This basically ensures that append() will not have to reallocate. |
| 45 | + cmds := make([]cli.Command, 0, len(parts)+1) |
| 46 | + |
| 47 | + for n, v := range parts { |
| 48 | + cmds = append(cmds, cli.Command{ |
| 49 | + Name: n, |
| 50 | + Usage: fmt.Sprintf("Install %s.", v), |
| 51 | + Action: func(c *cli.Context) { installComponent(c, n) }, |
| 52 | + }) |
| 53 | + } |
| 54 | + cmds = append(cmds, cli.Command{ |
| 55 | + Name: "platform", |
| 56 | + Usage: "Install the entire platform", |
| 57 | + Action: installPlatform, |
| 58 | + Flags: []cli.Flag{ |
| 59 | + cli.StringFlag{ |
| 60 | + Name: "units, u", |
| 61 | + Value: "units/", |
| 62 | + Usage: "The path to the Deis Kubernetes JSON unit files.", |
| 63 | + EnvVar: "DEIS_K8S_UNITS", |
| 64 | + }, |
| 65 | + cli.StringFlag{ |
| 66 | + Name: "registry, r", |
| 67 | + Usage: "The URL to a Docker registry that holds Deis images images.", |
| 68 | + EnvVar: "DEV_REGISTRY", |
| 69 | + }, |
| 70 | + }, |
| 71 | + }) |
| 72 | + |
| 73 | + return cmds |
| 74 | +} |
| 75 | + |
| 76 | +func installPlatform(c *cli.Context) { |
| 77 | + fmt.Println("Installing platform") |
| 78 | +} |
| 79 | +func installComponent(c *cli.Context, name string) { |
| 80 | + fmt.Printf("Installing component '%s' is currently not supported.\n", name) |
| 81 | + os.Exit(1) |
| 82 | +} |
0 commit comments