neithere / argh

An argparse wrapper that doesn't make you say "argh" each time you deal with it.
http://argh.rtfd.org
GNU Lesser General Public License v3.0
369 stars 56 forks source link

Store dispatch() result without printing to stdout? #40

Closed neithere closed 11 years ago

neithere commented 11 years ago

I like the default assumption to print to stdout. It’s the most common case, and it makes developing with argh faster.

However, I’ve stumbled upon a case where I want argh to dispatch a command, but then return the result of that function, so I can process it further. Is there a way to do this?

Note: This issue has been automatically migrated from Bitbucket Created by Zearin on 2013-03-01 16:49:30+00:00, last updated: 2013-03-01 22:32:30+00:00

neithere commented 11 years ago

If I understand your use case correctly, it is already supported:

#!python
result = dispatch(p, output_file=None)

See the API reference.

If something is unclear or you have any further ideas, please don't hesitate reopening this issue. :-)

P.S.: note that only lines that would go to output_file can be collected this way. Errors will still go to errors_file (which default value is sys.stderr).

Note: This comment has been automatically migrated from Bitbucket Created by @neithere on 2013-03-01 22:32:30+00:00