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:
|
class RemoteCommand:
|
||||||
|
|
||||||
name: str = ''
|
name: str = ''
|
||||||
|
|||||||
@ -11,8 +11,8 @@ from kitty.fast_data_types import patch_color_profiles
|
|||||||
from kitty.rgb import Color
|
from kitty.rgb import Color
|
||||||
|
|
||||||
from .base import (
|
from .base import (
|
||||||
MATCH_TAB_OPTION, MATCH_WINDOW_OPTION, ArgsType, Boss, PayloadGetType,
|
MATCH_TAB_OPTION, MATCH_WINDOW_OPTION, ArgsType, Boss, ParsingOfArgsFailed,
|
||||||
PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType, Window
|
||||||
)
|
)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
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] = {}
|
final_colors: Dict[str, int] = {}
|
||||||
cursor_text_color: Optional[Union[int, bool]] = False
|
cursor_text_color: Optional[Union[int, bool]] = False
|
||||||
if not opts.reset:
|
if not opts.reset:
|
||||||
|
try:
|
||||||
final_colors, cursor_text_color = parse_colors(args)
|
final_colors, cursor_text_color = parse_colors(args)
|
||||||
|
except Exception as err:
|
||||||
|
raise ParsingOfArgsFailed(str(err)) from err
|
||||||
ans = {
|
ans = {
|
||||||
'match_window': opts.match, 'match_tab': opts.match_tab,
|
'match_window': opts.match, 'match_tab': opts.match_tab,
|
||||||
'all': opts.all or opts.reset, 'configured': opts.configured or opts.reset,
|
'all': opts.all or opts.reset, 'configured': opts.configured or opts.reset,
|
||||||
|
|||||||
@ -10,8 +10,7 @@ import types
|
|||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from typing import (
|
from typing import (
|
||||||
Any, Dict, Generator, Iterable, List, Optional, Tuple,
|
Any, Dict, Generator, Iterable, List, Optional, Tuple, Union, cast
|
||||||
Union, cast
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from .cli import emph, parse_args
|
from .cli import emph, parse_args
|
||||||
@ -19,7 +18,7 @@ from .cli_stub import RCOptions
|
|||||||
from .constants import appname, version
|
from .constants import appname, version
|
||||||
from .fast_data_types import read_command_response
|
from .fast_data_types import read_command_response
|
||||||
from .rc.base import (
|
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
|
no_response as no_response_sentinel, parse_subcommand_cli
|
||||||
)
|
)
|
||||||
from .typing import BossType, WindowType
|
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(
|
raise SystemExit('{} is not a known command. Known commands are: {}'.format(
|
||||||
emph(cmd), ', '.join(x.replace('_', '-') for x in all_command_names())))
|
emph(cmd), ', '.join(x.replace('_', '-') for x in all_command_names())))
|
||||||
opts, items = parse_subcommand_cli(c, items)
|
opts, items = parse_subcommand_cli(c, items)
|
||||||
|
try:
|
||||||
payload = c.message_to_kitty(global_opts, opts, items)
|
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:
|
if global_opts.no_command_response is not None:
|
||||||
no_response = global_opts.no_command_response # type: ignore
|
no_response = global_opts.no_command_response # type: ignore
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -16,9 +16,9 @@ from .cli import (
|
|||||||
title
|
title
|
||||||
)
|
)
|
||||||
from .cli_stub import RCOptions
|
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 (
|
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
|
display_subcommand_help, parse_subcommand_cli
|
||||||
)
|
)
|
||||||
from .types import run_once
|
from .types import run_once
|
||||||
@ -205,7 +205,7 @@ def real_main(global_opts: RCOptions) -> None:
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
run_cmd(global_opts, cmd, func, opts, items)
|
run_cmd(global_opts, cmd, func, opts, items)
|
||||||
except SystemExit as e:
|
except (SystemExit, ParsingOfArgsFailed) as e:
|
||||||
print_err(e)
|
print_err(e)
|
||||||
continue
|
continue
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user