Skip to content

Instantly share code, notes, and snippets.

@chadgh
Created June 20, 2012 17:50
Show Gist options
  • Select an option

  • Save chadgh/2961165 to your computer and use it in GitHub Desktop.

Select an option

Save chadgh/2961165 to your computer and use it in GitHub Desktop.
simple python module that provides a few useful setups for other command line python scripts. Requires plumbum
#!/usr/bin/python
import sys
import argparse
from plumbum import local, FG, BG
local = local
FG = FG
BG = BG
def getArgParser(program=__file__, desc=''):
"""Generates a default argparser for command line python scripts."""
parser = argparse.ArgumentParser(prog=program, description=desc)
parser.add_argument('-v', '--verbose', action='store_true', default=False, help="display actual commands executed")
parser.add_argument('-t', '--test', action='store_true', default=False, help="display actual commands executed, but don't execute")
return parser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment