Fix #4084
This commit is contained in:
parent
3cea8f24d4
commit
1d1d55e2b4
@ -105,6 +105,10 @@ active tab, one the previously active tab and so on.
|
||||
'''
|
||||
|
||||
|
||||
class ParsingOfArgsFailed(ValueError):
|
||||
pass
|
||||
|
||||
|
||||
class RemoteCommand:
|
||||
|
||||
name: str = ''
|
||||
|
||||
@ -11,8 +11,8 @@ from kitty.fast_data_types import patch_color_profiles
|
||||
from kitty.rgb import Color
|
||||
|
||||
from .base import (
|
||||
MATCH_TAB_OPTION, MATCH_WINDOW_OPTION, ArgsType, Boss, PayloadGetType,
|
||||
PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
||||
MATCH_TAB_OPTION, MATCH_WINDOW_OPTION, ArgsType, Boss, ParsingOfArgsFailed,
|
||||
PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@ -76,7 +76,10 @@ this option, any color arguments are ignored and --configured and --all are impl
|
||||
final_colors: Dict[str, int] = {}
|
||||
cursor_text_color: Optional[Union[int, bool]] = False
|
||||
if not opts.reset:
|
||||
final_colors, cursor_text_color = parse_colors(args)
|
||||
try:
|
||||
final_colors, cursor_text_color = parse_colors(args)
|
||||
except Exception as err:
|
||||
raise ParsingOfArgsFailed(str(err)) from err
|
||||
ans = {
|
||||
'match_window': opts.match, 'match_tab': opts.match_tab,
|
||||
'all': opts.all or opts.reset, 'configured': opts.configured or opts.reset,
|
||||
|
||||
@ -10,8 +10,7 @@ import types
|
||||
from contextlib import suppress
|
||||
from functools import partial
|
||||
from typing import (
|
||||
Any, Dict, Generator, Iterable, List, Optional, Tuple,
|
||||
Union, cast
|
||||
Any, Dict, Generator, Iterable, List, Optional, Tuple, Union, cast
|
||||
)
|
||||
|
||||
from .cli import emph, parse_args
|
||||
@ -19,7 +18,7 @@ from .cli_stub import RCOptions
|
||||
from .constants import appname, version
|
||||
from .fast_data_types import read_command_response
|
||||
from .rc.base import (
|
||||
PayloadGetter, all_command_names, command_for_name,
|
||||
ParsingOfArgsFailed, PayloadGetter, all_command_names, command_for_name,
|
||||
no_response as no_response_sentinel, parse_subcommand_cli
|
||||
)
|
||||
from .typing import BossType, WindowType
|
||||
@ -177,7 +176,10 @@ def main(args: List[str]) -> None:
|
||||
raise SystemExit('{} is not a known command. Known commands are: {}'.format(
|
||||
emph(cmd), ', '.join(x.replace('_', '-') for x in all_command_names())))
|
||||
opts, items = parse_subcommand_cli(c, items)
|
||||
payload = c.message_to_kitty(global_opts, opts, items)
|
||||
try:
|
||||
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:
|
||||
|
||||
@ -16,9 +16,9 @@ from .cli import (
|
||||
title
|
||||
)
|
||||
from .cli_stub import RCOptions
|
||||
from .constants import cache_dir, version, kitty_face
|
||||
from .constants import cache_dir, kitty_face, version
|
||||
from .rc.base import (
|
||||
RemoteCommand, all_command_names, command_for_name,
|
||||
ParsingOfArgsFailed, RemoteCommand, all_command_names, command_for_name,
|
||||
display_subcommand_help, parse_subcommand_cli
|
||||
)
|
||||
from .types import run_once
|
||||
@ -205,7 +205,7 @@ def real_main(global_opts: RCOptions) -> None:
|
||||
else:
|
||||
try:
|
||||
run_cmd(global_opts, cmd, func, opts, items)
|
||||
except SystemExit as e:
|
||||
except (SystemExit, ParsingOfArgsFailed) as e:
|
||||
print_err(e)
|
||||
continue
|
||||
except KeyboardInterrupt:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user