Dead-simple command line arguments for python scripts.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Dead-simple command line arguments for python scripts.

I got sick of re-learning the argparse module every time I just needed to pass in a few simple command line arguments for a python script. dont_argue skips the boring stuff and lets you get started in a flash.


dont_argue provides the decorator supply_args, use it on a function and that function's arguments will be provided from the command line.

Check it out:

from dont_argue import supply_args
def main(name, location, *friends):
    friends = ', '.join(friends)
    print 'Hello {} from {} and your friends {}'.format(name, location, friends)

# Now to kick things off we just call the function, the arguments come from the
# command line, so we don't give any here.

Try it out:

$ ./ Joe Alabama Jake Drake
Hello Joe from Alabama and your friends Jake, Drake

If that's all you need, then you're done! Also notice how all the extra arguments get packed up into *friends as expected.

You can also work with command line options by specifying keyword arguments for your function. They can be specified on the command line using the --option=value or --option value syntax.

def main(name, mood='FRIENDLY'):
    if mood == 'FRIENDLY':
        print 'Hello {}! Welcome here!'.format(name)
    elif mood == 'ANGRY':
        print 'Hey {}! Get out of my house!'.format(name)

Now we can specify mood or not. Also note that providing too few arguments or using the -h flag will display usage information.

$ ./ Joe
Hello Joe! Welcome here!
$ ./ Joe --mood ANGRY
Hey Joe! Get out of my house!
$ ./ -h
usage: [-h] [--mood MOOD] name

positional arguments:

optional arguments:
  -h, --help   show this help message and exit
  --mood MOOD

Arbitrary keyword arguments don't make a ton of sense on the command line, so you must explicitly declare your keyword arguments, **kwargs won't work with command line options.