Add argument parser
This commit is contained in:
20
ugit/cli.py
20
ugit/cli.py
@@ -1,2 +1,22 @@
|
|||||||
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
args = parse_args()
|
||||||
|
args.func(args)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args():
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
|
commands = parser.add_subparsers(dest="command")
|
||||||
|
commands.required = True
|
||||||
|
|
||||||
|
init_parser = commands.add_parser("init")
|
||||||
|
init_parser.set_defaults(func=init)
|
||||||
|
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def init(args):
|
||||||
print("Hello, World!")
|
print("Hello, World!")
|
||||||
|
|||||||
Reference in New Issue
Block a user