summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Firth <dan.firth@codethink.co.uk>2016-11-30 14:53:39 +0000
committerDaniel Firth <dan.firth@codethink.co.uk>2016-11-30 14:59:16 +0000
commit553c1b0accefe67649f6facb10cfe45143b3cf34 (patch)
treee25bc4c112b6a016befdec2563afeb932042b3a0
parentde60729f09489a1144d17623295281d764b75c7e (diff)
downloadybd-lc/docopt.tar.gz
Use docopt for argument parsinglc/docopt
-rw-r--r--requirements.freeze.txt1
-rw-r--r--requirements.txt1
-rwxr-xr-xybd.py19
-rw-r--r--ybd/app.py6
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
diff --git a/ybd.py b/ybd.py
index 933e315..a41bfce 100755
--- a/ybd.py
+++ b/ybd.py
@@ -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')
diff --git a/ybd/app.py b/ybd/app.py
index 51dc2d9..7aa1e26 100644
--- a/ybd/app.py
+++ b/ybd/app.py
@@ -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'] = []