Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39d9250
commit ffa38af
Showing
4 changed files
with
35 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
argparse==1.2.1 | ||
nose==1.2.1 | ||
mock==0.8.0 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,22 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
import argparse | ||
import functools | ||
|
||
from blah.commands import find_command | ||
from blah.commands import commands | ||
|
||
def main(): | ||
command_name = sys.argv[1] | ||
command = find_command(command_name) | ||
if command is None: | ||
print 'command not recognised: {0}'.format(command_name) | ||
else: | ||
command() | ||
parser = argparse.ArgumentParser() | ||
subparsers = parser.add_subparsers() | ||
|
||
for command_name, command in commands.iteritems(): | ||
subparser = subparsers.add_parser(command_name) | ||
subparser.set_defaults(func=command.execute) | ||
command.create_parser(subparser) | ||
|
||
args = parser.parse_args() | ||
args.func(args) | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains 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