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

Suppress return output. #175

Open
TheChymera opened this issue Mar 3, 2023 · 2 comments
Open

Suppress return output. #175

TheChymera opened this issue Mar 3, 2023 · 2 comments

Comments

@TheChymera
Copy link

As it stands, if the function which I dispatch has a return statement, all of that ends up in my stdout. Is there any way to suppress this?

@neithere
Copy link
Owner

neithere commented Mar 4, 2023

That's the expected and desired behaviour: you write a function that takes some arguments and returns something, then simply "dispatch" it via argh and it magically becomes also a CLI endpoint which takes arguments and returns text which you can redirect elsewhere, as you would do in Python.

Could you please share your use case?

@TheChymera
Copy link
Author

it's a validator function, basically it checks if an input directory matches some standard conventions, logs errors or warnings, and returns a very large list of dictionaries for valid files. That's hardly usable as such in the CLI and clutters the terminal.

The thing is stdout and return are two different things. It seems a bit strange that return would end up in the terminal window with everything else.
I could add a return_metadata parameter which is set to False by default and then I would need to remember to always enable it for Python usage, but that would unnecessarily complicate function usage.
Another approach would be to do the same thing via a wrapper function, but the validation is done using said list of dictionaries so that variable is passed around anyway, in a sense this wrapper would just emulate the aforementioned solution.

I really think the most elegant way to do it would be if I could tell argh to just suppress return output. Is there really no way to do that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants