-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommands.py
More file actions
37 lines (31 loc) · 771 Bytes
/
commands.py
File metadata and controls
37 lines (31 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from attach import Attach
from detach import Detach
from clean import Clean
from sync import Sync
from clone import Clone
from default import Default
class Commands():
cmds={"attach":lambda:Attach(),
"detach":lambda:Detach(),
"clean":lambda:Clean(),
"sync":lambda:Sync(),
"clone":lambda:Clone()
}
forbiddance=["rm"]
def __init__(self, cmd_name):
if cmd_name in self.forbiddance:
print "The %s is forbidden command in mgit! Please use git." % cmd_name
self.cmd = None
return
if cmd_name in self.cmds.keys():
self.cmd = self.cmds[cmd_name]()
else:
self.cmd = Default()
def print_usages(self):
for k,v in self.cmds.items():
if v:
v().print_usage()
def run(self, args):
if not self.cmd:
return;
self.cmd.run(args)