main.go 3.1 KB

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