Created
April 7, 2022 00:33
-
-
Save kidd/938d0232b7a5aff8dbff1c44b7dffba8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 testing(foo, fname, **kwargs): | |
print(foo, fname, kwargs) | |
def parse_args(a): | |
r, extra = [], [] | |
for i in a: | |
if "--" in i and not "=" in i: | |
print("error") | |
if "--" in i: | |
r.append(re.split("=", i[2:], 2)) | |
else: | |
extra.append(i) | |
return dict(r + [['__extra', extra]]) | |
cmds = { "testing": testing } | |
if __name__ == "__main__": | |
cmds[sys.argv[1]](**parse_args(*sys.argv[2:])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment