template.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //go:build exclude
  2. // License: GPLv3 Copyright: 2022, Kovid Goyal, <kovid at kovidgoyal.net>
  3. // Code generated by gen-go-code.py; DO NOT EDIT.
  4. package at
  5. import (
  6. "fmt"
  7. "strings"
  8. "time"
  9. "kitty/tools/cli"
  10. "kitty/tools/utils"
  11. )
  12. var _ = fmt.Print
  13. var _ = strings.Join
  14. type options_CMD_NAME_type struct {
  15. OPTIONS_DECLARATION_CODE
  16. }
  17. var options_CMD_NAME options_CMD_NAME_type
  18. type CMD_NAME_json_type struct {
  19. JSON_DECLARATION_CODE
  20. }
  21. func create_payload_CMD_NAME(io_data *rc_io_data, cmd *cli.Command, args []string) (err error) {
  22. payload := CMD_NAME_json_type{}
  23. JSON_INIT_CODE
  24. io_data.rc.Payload = payload
  25. return
  26. }
  27. func create_rc_CMD_NAME(args []string) (*utils.RemoteControlCmd, error) {
  28. rc := utils.RemoteControlCmd{
  29. Cmd: "CLI_NAME",
  30. Version: ProtocolVersion,
  31. NoResponse: NO_RESPONSE_BASE,
  32. Stream: STREAM_WANTED,
  33. }
  34. if rc.Stream {
  35. stream_id, err := utils.HumanRandomId(128)
  36. if err != nil {
  37. return nil, err
  38. }
  39. rc.StreamId = stream_id
  40. }
  41. if IS_ASYNC {
  42. async_id, err := utils.HumanRandomId(128)
  43. if err != nil {
  44. return nil, err
  45. }
  46. rc.Async = async_id
  47. }
  48. return &rc, nil
  49. }
  50. func run_CMD_NAME(cmd *cli.Command, args []string) (return_code int, err error) {
  51. err = cmd.GetOptionValues(&options_CMD_NAME)
  52. if err != nil {
  53. return
  54. }
  55. rc, err := create_rc_CMD_NAME(args)
  56. if err != nil {
  57. return
  58. }
  59. nrv, err := cli.GetOptionValue[bool](cmd, "NoResponse")
  60. if err == nil {
  61. rc.NoResponse = nrv
  62. }
  63. var timeout float64 = WAIT_TIMEOUT
  64. rt, err := cli.GetOptionValue[float64](cmd, "ResponseTimeout")
  65. if err == nil {
  66. timeout = rt
  67. }
  68. io_data := rc_io_data{
  69. cmd: cmd,
  70. rc: rc,
  71. timeout: time.Duration(timeout * float64(time.Second)),
  72. string_response_is_err: STRING_RESPONSE_IS_ERROR,
  73. }
  74. err = create_payload_CMD_NAME(&io_data, cmd, args)
  75. if err != nil {
  76. return
  77. }
  78. err = send_rc_command(&io_data)
  79. return
  80. }
  81. func setup_CMD_NAME(parent *cli.Command) *cli.Command {
  82. ans := parent.AddSubCommand(&cli.Command{
  83. Name: "CLI_NAME",
  84. Usage: "ARGSPEC",
  85. ShortDescription: "SHORT_DESC",
  86. HelpText: "LONG_DESC",
  87. Run: run_CMD_NAME,
  88. })
  89. ADD_FLAGS_CODE
  90. return ans
  91. }
  92. func init() {
  93. register_at_cmd(setup_CMD_NAME)
  94. }