cli.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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: "manage which console container is used",
  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: "engine",
  45. Usage: "manage which Docker engine is used",
  46. HideHelp: true,
  47. Subcommands: engineSubcommands(),
  48. },
  49. {
  50. Name: "entrypoint",
  51. HideHelp: true,
  52. SkipFlagParsing: true,
  53. Action: entrypointAction,
  54. },
  55. {
  56. Name: "env",
  57. ShortName: "e",
  58. Usage: "env command",
  59. HideHelp: true,
  60. SkipFlagParsing: true,
  61. Action: envAction,
  62. },
  63. serviceCommand(),
  64. {
  65. Name: "os",
  66. Usage: "operating system upgrade/downgrade",
  67. HideHelp: true,
  68. Subcommands: osSubcommands(),
  69. },
  70. {
  71. Name: "tls",
  72. Usage: "setup tls configuration",
  73. HideHelp: true,
  74. Subcommands: tlsConfCommands(),
  75. },
  76. installCommand,
  77. selinuxCommand(),
  78. }
  79. app.Run(os.Args)
  80. }