Better error message for +launch
This commit is contained in:
parent
90164dfee7
commit
2105940286
11
__main__.py
11
__main__.py
@ -49,13 +49,22 @@ def complete(args: List[str]) -> None:
|
|||||||
def launch(args: List[str]) -> None:
|
def launch(args: List[str]) -> None:
|
||||||
import runpy
|
import runpy
|
||||||
sys.argv = args[1:]
|
sys.argv = args[1:]
|
||||||
|
try:
|
||||||
exe = args[1]
|
exe = args[1]
|
||||||
|
except IndexError:
|
||||||
|
raise SystemExit(
|
||||||
|
'usage: kitty +launch script.py [arguments to be passed to script.py ...]\n\n'
|
||||||
|
'script.py will be run with full access to kitty code. If script.py is '
|
||||||
|
'prefixed with a : it will be searched for in PATH'
|
||||||
|
)
|
||||||
if exe.startswith(':'):
|
if exe.startswith(':'):
|
||||||
import shutil
|
import shutil
|
||||||
q = shutil.which(exe[1:])
|
q = shutil.which(exe[1:])
|
||||||
if not q:
|
if not q:
|
||||||
raise SystemExit('{} not found in PATH'.format(args[1][1:]))
|
raise SystemExit(f'{exe[1:]} not found in PATH')
|
||||||
exe = q
|
exe = q
|
||||||
|
if not os.path.exists(exe):
|
||||||
|
raise SystemExit(f'{exe} does not exist')
|
||||||
runpy.run_path(exe, run_name='__main__')
|
runpy.run_path(exe, run_name='__main__')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user