Created
July 5, 2011 05:56
-
-
Save amorton/1064312 to your computer and use it in GitHub Desktop.
My super simple Python CLI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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