main.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. // License: GPLv3 Copyright: 2022, Kovid Goyal, <kovid at kovidgoyal.net>
  2. package tool
  3. import (
  4. "fmt"
  5. "kitty/kittens/ask"
  6. "kitty/kittens/clipboard"
  7. "kitty/kittens/diff"
  8. "kitty/kittens/hints"
  9. "kitty/kittens/hyperlinked_grep"
  10. "kitty/kittens/icat"
  11. "kitty/kittens/show_key"
  12. "kitty/kittens/ssh"
  13. "kitty/kittens/themes"
  14. "kitty/kittens/transfer"
  15. "kitty/kittens/unicode_input"
  16. "kitty/tools/cli"
  17. "kitty/tools/cmd/at"
  18. "kitty/tools/cmd/benchmark"
  19. "kitty/tools/cmd/edit_in_kitty"
  20. "kitty/tools/cmd/mouse_demo"
  21. "kitty/tools/cmd/pytest"
  22. "kitty/tools/cmd/run_shell"
  23. "kitty/tools/cmd/show_error"
  24. "kitty/tools/cmd/update_self"
  25. "kitty/tools/tui"
  26. )
  27. var _ = fmt.Print
  28. func KittyToolEntryPoints(root *cli.Command) {
  29. root.Add(cli.OptionSpec{
  30. Name: "--version", Type: "bool-set", Help: "The current kitten version."})
  31. tui.PrepareRootCmd(root)
  32. // @
  33. at.EntryPoint(root)
  34. // update-self
  35. update_self.EntryPoint(root)
  36. // edit-in-kitty
  37. edit_in_kitty.EntryPoint(root)
  38. // clipboard
  39. clipboard.EntryPoint(root)
  40. // icat
  41. icat.EntryPoint(root)
  42. // ssh
  43. ssh.EntryPoint(root)
  44. // transfer
  45. transfer.EntryPoint(root)
  46. // unicode_input
  47. unicode_input.EntryPoint(root)
  48. // show_key
  49. show_key.EntryPoint(root)
  50. // mouse_demo
  51. root.AddSubCommand(&cli.Command{
  52. Name: "mouse-demo",
  53. ShortDescription: "Demo the mouse handling kitty implements for terminal programs",
  54. OnlyArgsAllowed: true,
  55. Run: func(cmd *cli.Command, args []string) (rc int, err error) {
  56. return mouse_demo.Run(args)
  57. },
  58. })
  59. // hyperlinked_grep
  60. hyperlinked_grep.EntryPoint(root)
  61. // ask
  62. ask.EntryPoint(root)
  63. // hints
  64. hints.EntryPoint(root)
  65. // hints
  66. diff.EntryPoint(root)
  67. // themes
  68. themes.EntryPoint(root)
  69. themes.ParseEntryPoint(root)
  70. // run-shell
  71. run_shell.EntryPoint(root)
  72. // show_error
  73. show_error.EntryPoint(root)
  74. // __pytest__
  75. pytest.EntryPoint(root)
  76. // __hold_till_enter__
  77. root.AddSubCommand(&cli.Command{
  78. Name: "__hold_till_enter__",
  79. Hidden: true,
  80. OnlyArgsAllowed: true,
  81. Run: func(cmd *cli.Command, args []string) (rc int, err error) {
  82. tui.ExecAndHoldTillEnter(args)
  83. return
  84. },
  85. })
  86. // __confirm_and_run_shebang__
  87. root.AddSubCommand(&cli.Command{
  88. Name: "__confirm_and_run_shebang__",
  89. Hidden: true,
  90. OnlyArgsAllowed: true,
  91. Run: func(cmd *cli.Command, args []string) (rc int, err error) {
  92. return confirm_and_run_shebang(args)
  93. },
  94. })
  95. // __generate_man_pages__
  96. root.AddSubCommand(&cli.Command{
  97. Name: "__generate_man_pages__",
  98. Hidden: true,
  99. OnlyArgsAllowed: true,
  100. Run: func(cmd *cli.Command, args []string) (rc int, err error) {
  101. q := root
  102. if len(args) > 0 {
  103. for _, scname := range args {
  104. sc := q.FindSubCommand(scname)
  105. if sc == nil {
  106. return 1, fmt.Errorf("No sub command named: %s found", scname)
  107. }
  108. if err = sc.GenerateManPages(1, true); err != nil {
  109. return 1, err
  110. }
  111. }
  112. } else {
  113. if err = q.GenerateManPages(1, false); err != nil {
  114. rc = 1
  115. }
  116. }
  117. return
  118. },
  119. })
  120. benchmark.EntryPoint(root)
  121. }