Start work on copy instructions

This commit is contained in:
Kovid Goyal
2022-02-27 22:03:38 +05:30
parent e5ba15949b
commit 77c9affc00
7 changed files with 55 additions and 20 deletions

6
kittens/ssh/copy.py Normal file
View File

@@ -0,0 +1,6 @@
#!/usr/bin/env python
# License: GPLv3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
class CopyInstruction:
pass

View File

@@ -26,18 +26,9 @@ against is the hostname used by the remote computer, not the name you pass
to SSH to connect to it.
''')
opt('remote_dir', '.local/share/kitty-ssh-kitten', option_type='relative_dir', long_text='''
The location on the remote computer where the files needed for this kitten
are installed. The location is relative to the HOME directory. Absolute paths or paths
that resolve to a location outside the HOME are not allowed.
opt('+copy', '', option_type='copy', add_to_default=False, long_text='''
''')
opt('shell_integration', 'inherit', long_text='''
Control the shell integration on the remote host. See ref:`shell_integration`
for details on how this setting works. The special value :code:`inherit` means
use the setting from kitty.conf. This setting is useful for overriding
integration on a per-host basis.''')
opt('+env', '', option_type='env', add_to_default=False, long_text='''
Specify environment variables to set on the remote host. Note that
environment variables can refer to each other, so if you use::
@@ -51,4 +42,18 @@ will delete the variable from the child process' environment. The definitions
are processed alphabetically. The special value :code:`_kitty_copy_env_var_`
will cause the value of the variable to be copied from the local machine.
''')
opt('remote_dir', '.local/share/kitty-ssh-kitten', option_type='relative_dir', long_text='''
The location on the remote computer where the files needed for this kitten
are installed. The location is relative to the HOME directory. Absolute paths or paths
that resolve to a location outside the HOME are not allowed.
''')
opt('shell_integration', 'inherit', long_text='''
Control the shell integration on the remote host. See ref:`shell_integration`
for details on how this setting works. The special value :code:`inherit` means
use the setting from kitty.conf. This setting is useful for overriding
integration on a per-host basis.''')
egr() # }}}

View File

@@ -1,12 +1,16 @@
# generated by gen-config.py DO NOT edit
import typing
from kittens.ssh.options.utils import env, hostname
from kittens.ssh.options.utils import copy, env, hostname, relative_dir
from kitty.conf.utils import merge_dicts
class Parser:
def copy(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
for k, v in copy(val, ans["copy"]):
ans["copy"][k] = v
def env(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
for k, v in env(val, ans["env"]):
ans["env"][k] = v
@@ -15,7 +19,7 @@ class Parser:
hostname(val, ans)
def remote_dir(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
ans['remote_dir'] = str(val)
ans['remote_dir'] = relative_dir(val)
def shell_integration(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
ans['shell_integration'] = str(val)
@@ -23,6 +27,7 @@ class Parser:
def create_result_dict() -> typing.Dict[str, typing.Any]:
return {
'copy': {},
'env': {},
}

View File

@@ -1,16 +1,18 @@
# generated by gen-config.py DO NOT edit
import typing
import kittens.ssh.copy
option_names = ( # {{{
'env', 'hostname', 'remote_dir', 'shell_integration') # }}}
'copy', 'env', 'hostname', 'remote_dir', 'shell_integration') # }}}
class Options:
hostname: str = '*'
remote_dir: str = '.local/share/kitty-ssh-kitten'
shell_integration: str = 'inherit'
copy: typing.Dict[str, kittens.ssh.copy.CopyInstruction] = {}
env: typing.Dict[str, str] = {}
config_paths: typing.Tuple[str, ...] = ()
config_overrides: typing.Tuple[str, ...] = ()
@@ -62,4 +64,5 @@ class Options:
defaults = Options()
defaults.copy = {}
defaults.env = {}

View File

@@ -4,6 +4,8 @@
from typing import Any, Dict, Optional, Iterable, Tuple
import posixpath
from ..copy import CopyInstruction
DELETE_ENV_VAR = '_delete_this_env_var_'
@@ -30,6 +32,10 @@ def env(val: str, current_val: Dict[str, str]) -> Iterable[Tuple[str, str]]:
yield val, DELETE_ENV_VAR
def copy(val: str, current_val: Dict[str, str]) -> Iterable[Tuple[str, CopyInstruction]]:
pass
def init_results_dict(ans: Dict[str, Any]) -> Dict[str, Any]:
ans['hostname'] = '*'
ans['per_host_dicts'] = {}