Skip to content

Instantly share code, notes, and snippets.

@amorton
Created July 5, 2011 05:56
Show Gist options
  • Save amorton/1064312 to your computer and use it in GitHub Desktop.
Save amorton/1064312 to your computer and use it in GitHub Desktop.
My super simple Python CLI
if __name__ == "__main__":
action = sys.argv[1] if len(sys.argv) > 1 else None
args = [
token
for token in sys.argv[2:]
if token.find("=") < 0
]
kwargs = dict(
token.split("=")
for token in sys.argv[2:]
if token.find("=") > 0
)
func = globals().get(action)
if func:
func(*args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment