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

Disable completion when not attached to a TTY #44

Closed neithere closed 11 years ago

neithere commented 11 years ago

I'm using argh as a dependency of the watchdog project. When I daemonise my watchdog process, I end up with the bash warnings in my logfile (as per #39).

This is easily handled with something like the following:


@@ -84,7 +84,7 @@ def dispatch(parser, argv=None, add_help_command=True,
     You can also mark arbitrary exceptions as "wrappable" by using the
     :func:`~argh.decorators.wrap_errors` decorator.
     """
-    if completion:
+    if completion and sys.stdout.isatty():
         autocomplete(parser)

Apologies for the lack of a pull req; I had a quick look but I'm unfamiliar with Bitbucket and I've never touched Mercurial :)

Note: This issue has been automatically migrated from Bitbucket Created by @mafrosis on 2013-08-20 02:09:01+00:00, last updated: 2013-08-20 08:39:17+00:00

neithere commented 11 years ago

Thanks for the report! I'm currently moving Argh to GitHub (because Travis is worth it). This repo is now lagging behind http://github.com/neithere/argh so you could fork that one if I don't apply the patch in the next couple of hours :)

Note: This comment has been automatically migrated from Bitbucket Created by @neithere on 2013-08-20 08:39:17+00:00

neithere commented 11 years ago

Fixed by @mafrosis in commit 549439eea038d2ad1c9b0e505853ca073f95303d.

There was actually a pull request which I accepted. Since it was created during my attempts to import issues from Bitbucket, the IDs got mixed up, so I had to reset everything and manually merge the commit again. :-)