Skip to content

A new command-line argument parser that uses introspective magic to figure things out.

Notifications You must be signed in to change notification settings

startling/argent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Argent.

Argent is a new argument parser for command-line programs in Python. It turns out Python already has objects that can take arbitrary arguments, supply defaults, and do things with them: they're called functions. For help messages, Argent uses some introspective magic on these functions and then analyzes your docstrings for more information. And you already detail your arguments meticulously in your docstrings, right?

Features

  • Easy syntax; no cascades of text, as in argparse. Use the Python function syntax you already know and love, with decorators for specifying parsers and subparsers.
  • Cleverness founded in introspective magic; on the other hand, it's only a little more magic than docutils, for example. There's no black magic metaclass hacking here.
  • So long as you format your docstrings how Argent expects you too, you'll get beautiful detailed help messages.

Examples

This is about the simplest you can do:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from argent import Parser

@Parser.from_function
def simplest():
    "Prints hello when you call it."
    print "hello!"

simplest.command_line()

This program's help message (run python simplest.py --help) is:

usage: simplest.py [--h] 

Prints hello when you call it.

optional flags:
   --h, --help   Display this help message and exit.

Here's a more featureful example, and there are more over at this other page.

Todo:

  • Flags that can take arguments -- like --flag argument.
  • Type checking; for now you have to assume everything will come in as strings.
  • Colorized help output?
  • Clean up the codebase, as always.
  • More documentation.

About

A new command-line argument parser that uses introspective magic to figure things out.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages