Skip to content

Commit 457c4f1

Browse files
committed
moved main code to a function
1 parent 5e76742 commit 457c4f1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tools/bash_completion/generator.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ def getHelpTxt(command=None):
1616
out, err = p.communicate()
1717
return out
1818

19-
if __name__ == '__main__':
20-
#commands = defaultdict(defaultdict(list))
19+
def parseCommands():
2120
commands = defaultdict(defaultdict)
2221
helpTxt = getHelpTxt()
2322
#print helpTxt
2423
for line in helpTxt.split('\n'):
2524
match = re.search(commandRegex, line)
2625
if match:
27-
print "have match"
2826
g = match.groupdict()
2927
commands[g["command"]]["helptxt"] = g["helptxt"]
3028
commands[g["command"]]["subcommands"] = []
@@ -35,7 +33,12 @@ def getHelpTxt(command=None):
3533
for line in helpTxt.split('\n'):
3634
match = re.search(subcommandRegex, line)
3735
if match:
38-
print match.groupdict()
36+
commands[commandKey]["subcommands"].append(match.groupdict())
37+
38+
print commands
39+
40+
if __name__ == '__main__':
41+
parseCommands()
3942

4043
# At this point we have a list of all the commands and sub commands
4144
# for each command create a Bash function

0 commit comments

Comments
 (0)