Make askpass a choice var

This commit is contained in:
Kovid Goyal 2022-03-15 13:14:53 +05:30
parent 868d57b818
commit 7168ceab94
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 14 additions and 5 deletions

View file

@ -107,14 +107,14 @@
The login shell to execute on the remote host. By default, the remote user account's
login shell is used.''')
opt('askpass', 'unless-set', long_text='''
opt('askpass', 'unless-set', choices=('unless-set', 'ssh', 'native'), long_text='''
Control the program SSH uses to ask for passwords or confirmation of host keys
etc. The default is to use kitty's native askpass, unless the SSH_ASKPASS
environment variable is set. Set it to :code:`ssh` to not interfere with the
normal ssh askpass mechanism at all, which typically means that ssh will prompt
at the terminal. Set it to :code:`native` to always use kitty's native,
built-in askpass implementation. Note that not using an askpass implementation
means that SSH needs to use the terminal before the connection is established
built-in askpass implementation. Note that not using the kitty askpass implementation
means that SSH might need to use the terminal before the connection is established
so the kitten cannot use the terminal to send data without an extra roundtrip,
adding to initial connection latency.
''')

View file

@ -8,7 +8,12 @@
class Parser:
def askpass(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
ans['askpass'] = str(val)
val = val.lower()
if val not in self.choices_for_askpass:
raise ValueError(f"The value {val} is not a valid choice for askpass")
ans["askpass"] = val
choices_for_askpass = frozenset(('unless-set', 'ssh', 'native'))
def copy(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
for k, v in copy(val, ans["copy"]):

View file

@ -3,6 +3,10 @@
import typing
import kittens.ssh.copy
if typing.TYPE_CHECKING:
choices_for_askpass = typing.Literal['unless-set', 'ssh', 'native']
else:
choices_for_askpass = str
option_names = ( # {{{
'askpass',
@ -18,7 +22,7 @@
class Options:
askpass: str = 'unless-set'
askpass: choices_for_askpass = 'unless-set'
cwd: str = ''
hostname: str = '*'
interpreter: str = 'sh'