diff options
author | Daniel Firth <dan.firth@codethink.co.uk> | 2016-11-30 14:53:39 +0000 |
---|---|---|
committer | Daniel Firth <dan.firth@codethink.co.uk> | 2016-11-30 14:59:16 +0000 |
commit | 553c1b0accefe67649f6facb10cfe45143b3cf34 (patch) | |
tree | e25bc4c112b6a016befdec2563afeb932042b3a0 | |
parent | de60729f09489a1144d17623295281d764b75c7e (diff) | |
download | ybd-lc/docopt.tar.gz |
Use docopt for argument parsinglc/docopt
-rw-r--r-- | requirements.freeze.txt | 1 | ||||
-rw-r--r-- | requirements.txt | 1 | ||||
-rwxr-xr-x | ybd.py | 19 | ||||
-rw-r--r-- | ybd/app.py | 6 |
4 files changed, 20 insertions, 7 deletions
diff --git a/requirements.freeze.txt b/requirements.freeze.txt index e3956ac..6d03731 100644 --- a/requirements.freeze.txt +++ b/requirements.freeze.txt @@ -7,3 +7,4 @@ bottle==0.12.1 cherrypy==8.1.2 riemann-client==6.3.0 fs==0.5.0 +docopt==0.6.2 diff --git a/requirements.txt b/requirements.txt index 5e618c1..13ca780 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,4 @@ bottle cherrypy riemann-client fs +docopt @@ -13,6 +13,23 @@ # You should have received a copy of the GNU General Public License along # with this program. If not, see <http://www.gnu.org/licenses/>. +"""YBD - Yaml Build Deploy Tool + +Usage: + ybd.py <target> <arch> + +Options: + -h --help Show this screen. +""" +from docopt import docopt +from ybd.app import config +import os import runpy -runpy.run_module('ybd') + +if __name__ == '__main__': + arguments = docopt(__doc__, version='YBD 16.42') + target = os.path.basename(os.path.splitext(arguments['<target>'])[0]) + config['target'] = target + config['arch'] = arguments['<arch>'] + runpy.run_module('ybd') @@ -131,13 +131,7 @@ def setup(args, original_cwd=""): config['program'] = os.path.basename(args[0]) config['my-version'] = get_version(os.path.dirname(__file__)) log('SETUP', '%s version is' % config['program'], config['my-version']) - if len(args) != 3: - sys.stdout.write("\nUsage: %s DEFINITION_FILE ARCH\n\n" % sys.argv[0]) - sys.exit(1) - log('SETUP', 'Running %s in' % args[0], os.getcwd()) - config['target'] = os.path.basename(os.path.splitext(args[1])[0]) - config['arch'] = args[2] config['sandboxes'] = [] config['overlaps'] = [] config['new-overlaps'] = [] |