Created
April 28, 2013 16:48
-
-
Save carlos-wong/5477470 to your computer and use it in GitHub Desktop.
python: parse arguments
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
def _ParseArguments(args): | |
cmd = None | |
opt = _Options() | |
arg = [] | |
for i in range(len(args)): | |
a = args[i] | |
if a == '-h' or a == '--help': | |
opt.help = True | |
elif not a.startswith('-'): | |
cmd = a | |
arg = args[i + 1:] | |
break | |
return cmd, opt, arg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment