kitty/kittens/remote_file/main.py
OBrutus 19a0bf0670 Merge origin/master into go-kitten-ports
Reconcile the three ported kittens with 529 upstream commits. Only conflicts
were in the shrunk resize_window/broadcast/remote_file main.py stubs (upstream
reformatted their OPTIONS strings); resolved by keeping upstream's formatting
plus the Go-port stubs (shrunk main, remote_file handle_result shim, dropped
-h alias). Go build + kitten tests pass; dev build regenerates CLI cleanly;
Python suite at baseline (1 pre-existing unrelated failure).
2026-08-18 16:18:54 +05:30

61 lines
1.6 KiB
Python

#!/usr/bin/env python
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
import sys
from kitty.typing_compat import BossType
from kitty.utils import command_for_open, open_cmd
from ..tui.handler import result_handler
# Must match kittens/remote_file/ssh.go is_ssh_kitten_sentinel. Kept importable
# here because kitty/window.py:handle_remote_file imports it directly.
is_ssh_kitten_sentinel = '!#*&$#($ssh-kitten)(##$'
def option_text() -> str:
# The -h short alias was intentionally dropped from --hostname below:
# Go's cli reserves -h for --help, and the only caller (internal to
# kitty) uses the long --hostname form.
return """\
--mode -m
choices=ask,edit
default=ask
Which mode to operate in.
--path -p
Path to the remote file.
--hostname
Hostname of the remote host.
--ssh-connection-data
The data used to connect over ssh.
"""
def main(args: list[str]) -> None:
raise SystemExit('This should be run as kitten remote_file')
@result_handler()
def handle_result(args: list[str], data: str | None, target_window_id: int, boss: BossType) -> None:
if data:
from kitty.fast_data_types import get_options
cmd = command_for_open(get_options().open_url_with)
open_cmd(cmd, data)
if __name__ == '__main__':
main(sys.argv)
elif __name__ == '__doc__':
cd = sys.cli_docs # type: ignore
cd['usage'] = ''
cd['options'] = option_text
cd['help_text'] = 'Ask the user what to do with the remote file. For internal use by kitty, do not run it directly.'
cd['short_desc'] = 'Handle remote files'