Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unpackaged scripts: after TUI interaction, trogon attempts to launch the final command in working dir, not the script dir #39

Open
alexhunsley opened this issue Jun 6, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@alexhunsley
Copy link

alexhunsley commented Jun 6, 2023

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!

@alexhunsley alexhunsley changed the title After TUI interaction, trogon attempts to launch the final command in working dir, not the script dir Unpackaged scripts: after TUI interaction, trogon attempts to launch the final command in working dir, not the script dir Jun 8, 2023
@darrenburns darrenburns added the bug Something isn't working label Jun 26, 2023
@koaning
Copy link

koaning commented Aug 8, 2023

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/[email protected]/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/[email protected]/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/[email protected]/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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants