Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gmolveau
GitHub Repository: gmolveau/python_full_course
Path: blob/master/examples/makefile/makefile_class.py
305 views
1
import argparse
2
import sys
3
4
5
class Make:
6
def __init__(self):
7
parser = argparse.ArgumentParser(description="Pretends to be git")
8
subparsers = parser.add_subparsers(dest="command")
9
parser_db = subparsers.add_parser(
10
"db",
11
description="db command",
12
help="manage the db",
13
)
14
args = parser.parse_args()
15
if not hasattr(self, args.command):
16
exit(1)
17
getattr(self, args.command)()
18
19
def db(self):
20
print("db command run")
21
22
23
if __name__ == "__main__":
24
Make()
25
26