mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
Simplify handling of --no-response
This commit is contained in:
@@ -31,7 +31,7 @@ def generate_stub() -> None:
|
||||
do(options_spec(), 'LaunchCLIOptions')
|
||||
|
||||
from .remote_control import global_options_spec
|
||||
do(global_options_spec(), 'RCOptions', extra_fields=['no_command_response: typing.Optional[bool]'])
|
||||
do(global_options_spec(), 'RCOptions')
|
||||
|
||||
from kittens.ask.main import option_text
|
||||
do(option_text(), 'AskCLIOptions')
|
||||
|
||||
@@ -32,8 +32,6 @@ using this option means that you will not be notified of failures.
|
||||
argspec = ''
|
||||
|
||||
def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: ArgsType) -> PayloadType:
|
||||
if opts.no_response:
|
||||
global_opts.no_command_response = True
|
||||
return {'match': opts.match}
|
||||
|
||||
def response_from_kitty(self, boss: Boss, window: Optional[Window], payload_get: PayloadGetType) -> ResponseType:
|
||||
|
||||
@@ -32,8 +32,6 @@ the command will exit with a success code.
|
||||
'''
|
||||
|
||||
def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: ArgsType) -> PayloadType:
|
||||
if opts.no_response:
|
||||
global_opts.no_command_response = True
|
||||
return {'match': opts.match, 'no_response': opts.no_response}
|
||||
|
||||
def response_from_kitty(self, boss: Boss, window: Optional[Window], payload_get: PayloadGetType) -> ResponseType:
|
||||
|
||||
@@ -37,8 +37,6 @@ the command will exit with a success code.
|
||||
''' + '\n\n\n' + MATCH_TAB_OPTION
|
||||
|
||||
def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: ArgsType) -> PayloadType:
|
||||
if opts.no_response:
|
||||
global_opts.no_command_response = True
|
||||
return {'match': opts.match, 'all': opts.all}
|
||||
|
||||
def response_from_kitty(self, boss: Boss, window: Optional[Window], payload_get: PayloadGetType) -> ResponseType:
|
||||
|
||||
@@ -63,8 +63,6 @@ instead of the active tab
|
||||
argspec = '[CMD ...]'
|
||||
|
||||
def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: ArgsType) -> PayloadType:
|
||||
if opts.no_response:
|
||||
global_opts.no_command_response = True
|
||||
ans = {'args': args or []}
|
||||
for attr, val in opts.__dict__.items():
|
||||
ans[attr] = val
|
||||
|
||||
@@ -78,8 +78,6 @@ the id of the new window will not be printed out.
|
||||
argspec = '[CMD ...]'
|
||||
|
||||
def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: ArgsType) -> PayloadType:
|
||||
if opts.no_response:
|
||||
global_opts.no_command_response = True
|
||||
return {'match': opts.match, 'title': opts.title, 'cwd': opts.cwd,
|
||||
'new_tab': opts.new_tab, 'tab_title': opts.tab_title,
|
||||
'window_type': opts.window_type, 'no_response': opts.no_response,
|
||||
|
||||
@@ -74,8 +74,6 @@ using this option means that you will not be notified of failures.
|
||||
argspec = ''
|
||||
|
||||
def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: ArgsType) -> PayloadType:
|
||||
if opts.no_response:
|
||||
global_opts.no_command_response = True
|
||||
return {
|
||||
'match': opts.match, 'action': opts.action, 'unit': opts.unit,
|
||||
'width': opts.width, 'height': opts.height, 'self': opts.self,
|
||||
|
||||
@@ -67,8 +67,6 @@ failed, the command will exit with a success code.
|
||||
def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: ArgsType) -> PayloadType:
|
||||
if len(args) != 1:
|
||||
self.fatal('Must specify path to exactly one PNG image')
|
||||
if opts.no_response:
|
||||
global_opts.no_command_response = True
|
||||
path = args[0]
|
||||
ret = {
|
||||
'match': opts.match,
|
||||
|
||||
@@ -162,7 +162,6 @@ def create_basic_command(name: str, payload: Any = None, no_response: bool = Fal
|
||||
|
||||
def main(args: List[str]) -> None:
|
||||
global_opts, items = parse_rc_args(args)
|
||||
global_opts.no_command_response = None
|
||||
|
||||
if not items:
|
||||
from kitty.shell import main as smain
|
||||
@@ -179,10 +178,9 @@ def main(args: List[str]) -> None:
|
||||
payload = c.message_to_kitty(global_opts, opts, items)
|
||||
except ParsingOfArgsFailed as err:
|
||||
exit(str(err))
|
||||
if global_opts.no_command_response is not None:
|
||||
no_response = global_opts.no_command_response # type: ignore
|
||||
else:
|
||||
no_response = c.no_response
|
||||
no_response = c.no_response
|
||||
if hasattr(opts, 'no_response'):
|
||||
no_response = opts.no_response
|
||||
send = create_basic_command(cmd, payload=payload, no_response=no_response)
|
||||
if not global_opts.to and 'KITTY_LISTEN_ON' in os.environ:
|
||||
global_opts.to = os.environ['KITTY_LISTEN_ON']
|
||||
|
||||
Reference in New Issue
Block a user