main.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. "github.com/urfave/cli"
  6. )
  7. func main() {
  8. app := cli.NewApp()
  9. app.Name = "kratos"
  10. app.Usage = "kratos tool"
  11. app.Version = Version
  12. app.Commands = []cli.Command{
  13. {
  14. Name: "build",
  15. Aliases: []string{"b"},
  16. Usage: "bazel build",
  17. Action: bazelAction,
  18. },
  19. {
  20. Name: "init",
  21. Aliases: []string{"i"},
  22. Usage: "create new project",
  23. Flags: []cli.Flag{
  24. cli.StringFlag{
  25. Name: "d",
  26. Value: "",
  27. Usage: "department name for create project",
  28. Destination: &p.Department,
  29. },
  30. cli.StringFlag{
  31. Name: "t",
  32. Value: "",
  33. Usage: "project type name for create project",
  34. Destination: &p.Type,
  35. },
  36. cli.StringFlag{
  37. Name: "n",
  38. Value: "",
  39. Usage: "project name for create project",
  40. Destination: &p.Name,
  41. },
  42. cli.StringFlag{
  43. Name: "o",
  44. Value: "",
  45. Usage: "project owner for create project",
  46. Destination: &p.Owner,
  47. },
  48. cli.BoolFlag{
  49. Name: "grpc",
  50. Usage: "whether to use grpc for create project",
  51. Destination: &p.WithGRPC,
  52. },
  53. },
  54. Action: runInit,
  55. },
  56. {
  57. Name: "update",
  58. Aliases: []string{"u"},
  59. Usage: "update bazel building configure",
  60. Action: updateAction,
  61. },
  62. {
  63. Name: "version",
  64. Aliases: []string{"v"},
  65. Usage: "kratos version",
  66. Action: func(c *cli.Context) error {
  67. fmt.Println(getVersion())
  68. return nil
  69. },
  70. },
  71. {
  72. Name: "upgrade",
  73. Usage: "kratos self-upgrade",
  74. Action: upgradeAction,
  75. },
  76. }
  77. err := app.Run(os.Args)
  78. if err != nil {
  79. panic(err)
  80. }
  81. }