From 49c011733958f36b366153e4759ef0a3f841edd0 Mon Sep 17 00:00:00 2001 From: OBrutus <37221337+OBrutus@users.noreply.github.com> Date: Mon, 17 Aug 2026 15:16:50 +0530 Subject: [PATCH] remote_file/broadcast/resize_window: untrack generated CLI files, drop dead ToLower, document -h removal --- kittens/broadcast/cli_generated.go | 66 -------------------------- kittens/broadcast/main.go | 5 +- kittens/remote_file/main.py | 6 +++ kittens/resize_window/cli_generated.go | 51 -------------------- 4 files changed, 8 insertions(+), 120 deletions(-) delete mode 100644 kittens/broadcast/cli_generated.go delete mode 100644 kittens/resize_window/cli_generated.go diff --git a/kittens/broadcast/cli_generated.go b/kittens/broadcast/cli_generated.go deleted file mode 100644 index e985be27c..000000000 --- a/kittens/broadcast/cli_generated.go +++ /dev/null @@ -1,66 +0,0 @@ -// Code generated by go_code.py; DO NOT EDIT. - -package broadcast -import "fmt" -import "github.com/kovidgoyal/kitty/tools/cli" -var _ = fmt.Sprintf -func create_cmd(root *cli.Command, run_func func(*cli.Command, *Options, []string)(int, error)) { -ans := root.AddSubCommand(&cli.Command{ -Name: "broadcast", -ShortDescription: "Broadcast typed text to kitty windows", -Usage: "[options] [initial text to send ...]", -HelpText: "Broadcast typed text to kitty windows. By default text is sent to all windows, unless one of the matching options is specified", -Run: func(cmd *cli.Command, args []string) (int, error) { -opts := Options{} -err := cmd.GetOptionValues(&opts) -if err != nil { return 1, err } -return run_func(cmd, &opts, args)}, -}) -ans.Add(cli.OptionSpec{ - Name: "--hide-input-toggle", - Type: "", - Dest: "HideInputToggle", - Help: "Key to press that will toggle hiding of the input in the broadcast window itself. Useful while typing a password, prevents the password from being visible on the screen.", - - Default: "Ctrl+Alt+Esc", -}) -ans.Add(cli.OptionSpec{ - Name: "--end-session", - Type: "", - Dest: "EndSession", - Help: "Key to press to end the broadcast session.", - - Default: "Ctrl+Esc", -}) -ans.Add(cli.OptionSpec{ - Name: "--match -m", - Type: "", - Dest: "Match", - Help: "The window to match. Match specifications are of the form: :italic:`field:query`. Where :italic:`field` can be one of: :code:`id`, :code:`title`, :code:`pid`, :code:`cwd`, :code:`cmdline`, :code:`num`, :code:`env`, :code:`var`, :code:`state`, :code:`neighbor`, :code:`session` and :code:`recent`. :italic:`query` is the expression to match. Expressions can be either a number or a regular expression, and can be :ref:`combined using Boolean operators `.\n\nThe special value :code:`all` matches all windows.\n\nFor numeric fields: :code:`id`, :code:`pid`, :code:`num` and :code:`recent`, the expression is interpreted as a number, not a regular expression. Negative values for :code:`id` match from the highest id number down, in particular, -1 is the most recently created window.\n\nThe field :code:`num` refers to the window position in the current tab, starting from zero and counting clockwise (this is the same as the order in which the windows are reported by the :ref:`kitten @ ls ` command).\n\nThe window id of the current window is available as the :envvar:`KITTY_WINDOW_ID` environment variable.\n\nThe field :code:`recent` refers to recently active windows in the currently active tab, with zero being the currently active window, one being the previously active window and so on.\n\nThe field :code:`neighbor` refers to a neighbor of the active window in the specified direction, which can be: :code:`left`, :code:`right`, :code:`top` or :code:`bottom`.\n\nThe field :code:`session` matches windows that were created in the specified session. Use the expression :code:`^$` to match windows that were not created in a session and :code:`.` to match the currently active session and :code:`~` to match either the currently active session or the last active session when no session is active.\n\nWhen using the :code:`env` field to match on environment variables, you can specify only the environment variable name or a name and value, for example, :code:`env:MY_ENV_VAR=2`.\n\nSimilarly, the :code:`var` field matches on user variables set on the window. You can specify name or name and value as with the :code:`env` field.\n\nThe field :code:`state` matches on the state of the window. Supported states are: :code:`active`, :code:`focused`, :code:`needs_attention`, :code:`parent_active`, :code:`parent_focused`, :code:`focused_os_window`, :code:`self`, :code:`overlay_parent`. Active windows are the windows that are active in their parent tab. There is only one focused window and it is the window to which keyboard events are delivered. If no window is focused, the last focused window is matched. The value :code:`focused_os_window` matches all windows in the currently focused OS window. The value :code:`self` matches the window in which the remote control command is run. The value :code:`overlay_parent` matches the window that is under the :code:`self` window, when the self window is an overlay.\n\nNote that you can use the :ref:`kitten @ ls ` command to get a list of windows.", - }) -ans.Add(cli.OptionSpec{ - Name: "--match-tab -t", - Type: "", - Dest: "MatchTab", - Help: "The tab to match. Match specifications are of the form: :italic:`field:query`. Where :italic:`field` can be one of: :code:`id`, :code:`index`, :code:`title`, :code:`window_id`, :code:`window_title`, :code:`pid`, :code:`cwd`, :code:`cmdline` :code:`env`, :code:`var`, :code:`state`, :code:`session` and :code:`recent`. :italic:`query` is the expression to match. Expressions can be either a number or a regular expression, and can be :ref:`combined using Boolean operators `.\n\nThe special value :code:`all` matches all tabs.\n\nFor numeric fields: :code:`id`, :code:`index`, :code:`window_id`, :code:`pid` and :code:`recent`, the expression is interpreted as a number, not a regular expression. Negative values for :code:`id`/:code:`window_id` match from the highest id number down, in particular, -1 is the most recently created tab/window.\n\nWhen using :code:`title` or :code:`id`, first a matching tab is looked for, and if not found a matching window is looked for, and the tab for that window is used.\n\nYou can also use :code:`window_id` and :code:`window_title` to match the tab that contains the window with the specified id or title.\n\nThe :code:`index` number is used to match the nth tab in the currently active OS window. The :code:`recent` number matches recently active tabs in the currently active OS window, with zero being the currently active tab, one the previously active tab and so on.\n\nThe field :code:`session` matches tabs that were created in the specified session. Use the expression :code:`^$` to match windows that were not created in a session and :code:`.` to match the currently active session and :code:`~` to match either the currently active session or the last active session when no session is active.\n\nWhen using the :code:`env` field to match on environment variables, you can specify only the environment variable name or a name and value, for example, :code:`env:MY_ENV_VAR=2`. Tabs containing any window with the specified environment variables are matched. Similarly, :code:`var` matches tabs containing any window with the specified user variable.\n\nThe field :code:`state` matches on the state of the tab. Supported states are: :code:`active`, :code:`focused`, :code:`needs_attention`, :code:`parent_active`, :code:`parent_focused` and :code:`focused_os_window`. Active tabs are the tabs that are active in their parent OS window. There is only one focused tab and it is the tab to which keyboard events are delivered. If no tab is focused, the last focused tab is matched. The value :code:`focused_os_window` matches all tabs in the currently focused OS window.\n\nNote that you can use the :ref:`kitten @ ls ` command to get a list of tabs.", - }) -} -type Options struct { -HideInputToggle string -EndSession string -Match string -MatchTab string -} -func (opts Options) AsCommandLine() (ans []string) { - sval := "" - _ = sval - sval = opts.HideInputToggle - if (sval != "Ctrl+Alt+Esc") { ans = append(ans, `--hide-input-toggle=` + sval)} - sval = opts.EndSession - if (sval != "Ctrl+Esc") { ans = append(ans, `--end-session=` + sval)} - sval = opts.Match - if (sval != "") { ans = append(ans, `--match=` + sval)} - sval = opts.MatchTab - if (sval != "") { ans = append(ans, `--match-tab=` + sval)} -return -} diff --git a/kittens/broadcast/main.go b/kittens/broadcast/main.go index f8ac1a24e..8fed72bbb 100644 --- a/kittens/broadcast/main.go +++ b/kittens/broadcast/main.go @@ -5,7 +5,6 @@ package broadcast import ( "encoding/base64" "os" - "strings" "github.com/kovidgoyal/kitty/tools/cli" "github.com/kovidgoyal/kitty/tools/cli/markup" @@ -83,7 +82,7 @@ func (h *handler) on_text(text string) error { } func (h *handler) on_key(e *loop.KeyEvent) error { - if e.MatchesPressOrRepeat(strings.ToLower(h.opts.HideInputToggle)) { + if e.MatchesPressOrRepeat(h.opts.HideInputToggle) { e.Handled = true h.hide_input = !h.hide_input h.lp.SetCursorVisible(!h.hide_input) @@ -94,7 +93,7 @@ func (h *handler) on_key(e *loop.KeyEvent) error { } return nil } - if e.MatchesPressOrRepeat(strings.ToLower(h.opts.EndSession)) { + if e.MatchesPressOrRepeat(h.opts.EndSession) { e.Handled = true h.lp.Quit(0) return nil diff --git a/kittens/remote_file/main.py b/kittens/remote_file/main.py index feec4c819..90eaefba2 100644 --- a/kittens/remote_file/main.py +++ b/kittens/remote_file/main.py @@ -26,6 +26,11 @@ Which mode to operate in. Path to the remote file. +''' + ( + # The -h short alias was intentionally dropped for --hostname below: + # Go's cli reserves -h for --help, and the only caller (internal to + # kitty) uses the long --hostname form. + '''\ --hostname Hostname of the remote host. @@ -33,6 +38,7 @@ Hostname of the remote host. --ssh-connection-data The data used to connect over ssh. ''' + ) def main(args: list[str]) -> None: diff --git a/kittens/resize_window/cli_generated.go b/kittens/resize_window/cli_generated.go deleted file mode 100644 index d25947b44..000000000 --- a/kittens/resize_window/cli_generated.go +++ /dev/null @@ -1,51 +0,0 @@ -// Code generated by go_code.py; DO NOT EDIT. - -package resize_window -import "fmt" -import "github.com/kovidgoyal/kitty/tools/cli" -var _ = fmt.Sprintf -func create_cmd(root *cli.Command, run_func func(*cli.Command, *Options, []string)(int, error)) { -ans := root.AddSubCommand(&cli.Command{ -Name: "resize_window", -ShortDescription: "Resize the current window interactively", -HelpText: "Resize the current window", -Run: func(cmd *cli.Command, args []string) (int, error) { -opts := Options{} -err := cmd.GetOptionValues(&opts) -if err != nil { return 1, err } -return run_func(cmd, &opts, args)}, -Hidden: true, -}) -ans.Add(cli.OptionSpec{ - Name: "--horizontal-increment", - Type: "int", - Dest: "HorizontalIncrement", - Help: "The base horizontal increment.", - - Default: "2", -}) -ans.Add(cli.OptionSpec{ - Name: "--vertical-increment", - Type: "int", - Dest: "VerticalIncrement", - Help: "The base vertical increment.", - - Default: "2", -}) -clone := root.AddClone(ans.Group, ans) -clone.Hidden = false -clone.Name = "resize-window" -} -type Options struct { -HorizontalIncrement int -VerticalIncrement int -} -func (opts Options) AsCommandLine() (ans []string) { - sval := "" - _ = sval - sval = fmt.Sprintf(`%d`, opts.HorizontalIncrement) - if (sval != `2`) { ans = append(ans, `--horizontal-increment=` + sval)} - sval = fmt.Sprintf(`%d`, opts.VerticalIncrement) - if (sval != `2`) { ans = append(ans, `--vertical-increment=` + sval)} -return -}