main.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package main
  2. import (
  3. cli "github.com/urfave/cli/v2"
  4. "os"
  5. )
  6. const VERSION = "0.0.1"
  7. func main() {
  8. app := &cli.App{
  9. Name: "sakish",
  10. Usage: "ELIP4NG management script shell. Default subcommand is 'repl'.",
  11. Version: VERSION,
  12. Flags: []cli.Flag{
  13. &cli.StringFlag{
  14. Name: "config",
  15. Aliases: []string{"c"},
  16. Usage: "config file path. if not specified, use default config at '/nagae/elip4ng/config/sakish.toml'.",
  17. },
  18. &cli.BoolFlag{
  19. Name: "suppress-warn",
  20. Aliases: []string{"no-warn"},
  21. Usage: "suppress runtime warning messages",
  22. },
  23. },
  24. Commands: []*cli.Command{
  25. {
  26. Name: "repl",
  27. Aliases: []string{},
  28. Usage: "start REPL mode",
  29. Flags: []cli.Flag{},
  30. Action: CmdRepl,
  31. },
  32. {
  33. Name: "exec",
  34. Aliases: []string{"e"},
  35. Usage: "execute a script file",
  36. Flags: []cli.Flag{
  37. &cli.BoolFlag{
  38. Name: "strict-mode",
  39. Aliases: []string{"s"},
  40. Usage: "enable ECMAScript strict mode",
  41. },
  42. &cli.BoolFlag{
  43. Name: "no-js-result-print",
  44. Aliases: []string{"nrp"},
  45. Usage: "do not print js result after execute",
  46. },
  47. },
  48. Action: CmdRun,
  49. },
  50. {
  51. Name: "version",
  52. Aliases: []string{"v", "ver"},
  53. Usage: "print version information",
  54. Flags: []cli.Flag{},
  55. Action: CmdVersion,
  56. },
  57. },
  58. }
  59. app.DefaultCommand = "repl"
  60. if err := app.Run(os.Args); err != nil {
  61. ErrorExit(err)
  62. }
  63. }