Unpackaged scripts: after TUI interaction, trogon attempts to launch the final command in working dir, not the script dir
alexhunsley opened this issue · 1 comments
alexhunsley commented
Possibly a misunderstanding on my behalf, but anyway:
I tried the nogroup_demo.py
verbatim, running it from a higher directory:
❯ cd /Users/alexhunsley/Documents/dev/
❯ mkdir test_dir
❯ cat > test_dir/nogroup_demo.py <then I pasted in the nogroup_demo src>
❯ python test_dir/nogroup_demo.py tui
<I did config in TUI interace, then hit CTRL-R>
Running python nogroup_demo.py add --category work -v --labels important sada
python: can't open file '/Users/alexhunsley/Documents/dev/test_dir/nogroup_demo.py':
[Errno 2] No such file or directory
So it's missing out the test_dir/
bit before the nogroup_demo.py
.
Trogon: 0.4.0
M1 MacBook Pro (16-inch, 2021)
Mac OS: 13.3.1 (a)
Python: 3.10.1
Click: 8.1.3
Thanks for making Trogon btw!
koaning commented
I think I'm hitting the same issue with this demo script.
import click
from trogon import tui
@tui()
@click.command()
@click.option("--count", default=1, help="Number of greetings.")
@click.option("--name", prompt="Your name",
help="The person to greet.")
def hello(count, name):
"""Simple program that greets NAME for a total of COUNT times."""
for x in range(count):
click.echo(f"Hello {name}!")
if __name__ == "__main__":
hello()
When I run it I get this traceback after hitting ctrl + r.
Traceback (most recent call last):
File "/Users/vincent/Development/prodigy/cli.py", line 17, in <module>
hello()
File "/Users/vincent/Development/prodigy/venv/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
File "/Users/vincent/Development/prodigy/venv/lib/python3.9/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/Users/vincent/Development/prodigy/venv/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/vincent/Development/prodigy/venv/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/vincent/Development/prodigy/venv/lib/python3.9/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/Users/vincent/Development/prodigy/venv/lib/python3.9/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
File "/Users/vincent/Development/prodigy/venv/lib/python3.9/site-packages/trogon/trogon.py", line 296, in wrapped_tui
Trogon(app, app_name=name, command_name=command, click_context=ctx).run()
File "/Users/vincent/Development/prodigy/venv/lib/python3.9/site-packages/trogon/trogon.py", line 264, in run
os.execvp(program_name, arguments)
File "/opt/homebrew/Cellar/python@3.9/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/os.py", line 574, in execvp
_execvpe(file, args)
File "/opt/homebrew/Cellar/python@3.9/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/os.py", line 616, in _execvpe
raise last_exc
File "/opt/homebrew/Cellar/python@3.9/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/os.py", line 607, in _execvpe
exec_func(fullname, *argrest)
FileNotFoundError: [Errno 2] No such file or directory