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

Destination `dest` option throwing error #108

Closed joshlk closed 8 years ago

joshlk commented 8 years ago

Hi,

Im trying to include a 'dest' option:

import argparse
import argh
from argh import arg

@arg('--foo', dest='bar')
def f(foo=None):
    pass

parser = argparse.ArgumentParser()
argh.set_default_command(parser, f)
argh.dispatch(parser)

However im getting an error:

Traceback (most recent call last):
  File "/home/josh/.PyCharm2016.2/config/scratches/scratch_21.py", line 12, in <module>
    argh.set_default_command(parser, f)
  File "/home/josh/anaconda2/lib/python2.7/site-packages/argh/assembling.py", line 287, in set_default_command
    sig=', '.join('/'.join(x) for x in xs)))
argh.exceptions.AssemblingError: f: argument --foo does not fit function signature: -f/--foo

Im using version v0.26.2. Any ideas?

BTW Great package - I've been looking for something like this for a while

joshlk commented 8 years ago

Sorry I have just realised how it doesn't make any sense dest'ing into a variable that doesn't exist in the function signature