cli.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package control
  2. import (
  3. "os"
  4. log "github.com/Sirupsen/logrus"
  5. "github.com/codegangsta/cli"
  6. "github.com/rancher/os/config"
  7. )
  8. func Main() {
  9. app := cli.NewApp()
  10. app.Name = os.Args[0]
  11. app.Usage = "Control and configure RancherOS"
  12. app.Version = config.VERSION
  13. app.Author = "Rancher Labs, Inc."
  14. app.EnableBashCompletion = true
  15. app.Before = func(c *cli.Context) error {
  16. if os.Geteuid() != 0 {
  17. log.Fatalf("%s: Need to be root", os.Args[0])
  18. }
  19. return nil
  20. }
  21. app.Commands = []cli.Command{
  22. {
  23. Name: "config",
  24. ShortName: "c",
  25. Usage: "configure settings",
  26. HideHelp: true,
  27. Subcommands: configSubcommands(),
  28. },
  29. {
  30. Name: "console",
  31. Usage: "console container commands",
  32. HideHelp: true,
  33. Subcommands: consoleSubcommands(),
  34. },
  35. {
  36. Name: "dev",
  37. ShortName: "d",
  38. Usage: "dev spec",
  39. HideHelp: true,
  40. SkipFlagParsing: true,
  41. Action: devAction,
  42. },
  43. {
  44. Name: "env",
  45. ShortName: "e",
  46. Usage: "env command",
  47. HideHelp: true,
  48. SkipFlagParsing: true,
  49. Action: envAction,
  50. },
  51. serviceCommand(),
  52. {
  53. Name: "os",
  54. Usage: "operating system upgrade/downgrade",
  55. HideHelp: true,
  56. Subcommands: osSubcommands(),
  57. },
  58. {
  59. Name: "tls",
  60. Usage: "setup tls configuration",
  61. HideHelp: true,
  62. Subcommands: tlsConfCommands(),
  63. },
  64. installCommand,
  65. selinuxCommand(),
  66. }
  67. app.Run(os.Args)
  68. }