main.go 3.3 KB

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