diff --git a/gen-go-code.py b/gen-go-code.py index 54ab4507a..957ef1bf0 100755 --- a/gen-go-code.py +++ b/gen-go-code.py @@ -126,14 +126,27 @@ def build_go_code(name: str, cmd: RemoteCommand, seq: OptionSpecSeq, template: s handled_fields: Set[str] = set() jc.extend(cmd.args.as_go_code(name, field_types, handled_fields)) + unhandled = {} + used_options = set() for field in json_fields: - if field.field in option_map: - o = option_map[field.field] + oq = (cmd.field_to_option_map or {}).get(field.field, field.field) + if oq in option_map: + o = option_map[oq] + used_options.add(oq) jc.append(f'payload.{field.struct_field_name} = options_{name}.{o.go_var_name}') elif field.field in handled_fields: pass else: - print(f'Cant map field: {field.field} for cmd: {name}', file=sys.stderr) + unhandled[field.field] = field + for x in tuple(unhandled): + if x == 'match_window' and 'match' in option_map and 'match' not in used_options: + used_options.add('match') + o = option_map['match'] + field = unhandled[x] + jc.append(f'payload.{field.struct_field_name} = options_{name}.{o.go_var_name}') + del unhandled[x] + if unhandled: + raise SystemExit(f'Cant map fields: {", ".join(unhandled)} for cmd: {name}') argspec = cmd.args.spec if argspec: @@ -228,7 +241,7 @@ def update_at_commands() -> None: os.remove(dest) with open(dest, 'w') as f: f.write(code) - print('TODO: test set_window_logo, set_window_background, set_font_size, send_text, env, scroll_window', file=sys.stderr) + print('\x1b[31mTODO\x1b[m: test set_window_logo, set_window_background, set_font_size, send_text, env, scroll_window', file=sys.stderr) def main() -> None: diff --git a/kitty/rc/base.py b/kitty/rc/base.py index d1df3a29a..05c96d81f 100644 --- a/kitty/rc/base.py +++ b/kitty/rc/base.py @@ -261,6 +261,7 @@ class RemoteCommand: options_class: Type[RCOptions] = RCOptions protocol_spec: str = '' argspec = args_count = args_completion = ArgsHandling() + field_to_option_map: Optional[Dict[str, str]] = None def __init__(self) -> None: self.desc = self.desc or self.short_desc diff --git a/kitty/rc/get_text.py b/kitty/rc/get_text.py index 404e3e313..4c016a921 100644 --- a/kitty/rc/get_text.py +++ b/kitty/rc/get_text.py @@ -69,6 +69,8 @@ class GetText(RemoteCommand): Get text from the window this command is run in, rather than the active window. ''' + field_to_option_map = {'wrap_markers': 'add_wrap_markers', 'cursor': 'add_cursor'} + def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: ArgsType) -> PayloadType: return { 'match': opts.match, diff --git a/kitty/rc/launch.py b/kitty/rc/launch.py index e85c59592..17e98180c 100644 --- a/kitty/rc/launch.py +++ b/kitty/rc/launch.py @@ -47,6 +47,11 @@ class Launch(RemoteCommand): logo_position/str: Window logo position as string or empty string to use default logo_alpha/float: Window logo alpha or -1 to use default self/bool: Boolean, if True use tab the command was run in + os_window_title/str: Title for OS Window + os_window_name/str: WM_NAME for OS Window + os_window_class/str: WM_CLASS for OS Window + color/list.str: list of color specifications such as foreground=red + watcher/list.str: list of paths to watcher files ''' short_desc = 'Run an arbitrary process in a new window/tab'