Validate command line args to @ goto-layout better

This commit is contained in:
Kovid Goyal
2021-05-13 20:46:37 +05:30
parent e089e9c121
commit 4125ac013f

View File

@@ -29,10 +29,9 @@ class GotoLayout(RemoteCommand):
argspec = 'LAYOUT_NAME' argspec = 'LAYOUT_NAME'
def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: ArgsType) -> PayloadType: def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: ArgsType) -> PayloadType:
try: if len(args) != 1:
return {'layout': args[0], 'match': opts.match} self.fatal('Exactly one layout must be specified')
except IndexError: return {'layout': args[0], 'match': opts.match}
raise self.fatal('No layout specified')
def response_from_kitty(self, boss: Boss, window: Optional[Window], payload_get: PayloadGetType) -> ResponseType: def response_from_kitty(self, boss: Boss, window: Optional[Window], payload_get: PayloadGetType) -> ResponseType:
tabs = self.tabs_for_match_payload(boss, window, payload_get) tabs = self.tabs_for_match_payload(boss, window, payload_get)