]> sigrok.org Git - sigrok-util.git/blobdiff - source/new-driver
new-driver: split assignment and conditional
[sigrok-util.git] / source / new-driver
index 937a6741292fe6d33793e7817489c6f02dc7d31d..b584368c78b16627478253207b7b7aa47fa334a9 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 ##
 ## This file is part of the sigrok-util project.
 ##
@@ -178,23 +178,25 @@ if __name__ == '__main__':
     author, email = parse_gitconfig()
 
     parser = ArgumentParser(description='Bootstrap a new sigrok hardware driver')
-    parser.add_argument('name', help='new driver name')
-    parser.add_argument('--giturl', default=defaulturl,
+    parser.add_argument('name', nargs='*', default=[], help='new driver name')
+    parser.add_argument('--giturl', '-u', default=defaulturl,
                         help='URL of the libsigrok git repository '
                         '(defaults to {0})'.format(defaulturl))
-    parser.add_argument('--tmpl-dir', default=defaultdir,
+    parser.add_argument('--tmpl-dir', '-t', default=defaultdir,
                         help='Directory in which the templates are stored '
                         '(defaults to {0})'.format(defaultdir))
-    parser.add_argument('--author', default=author, required=not author,
+    parser.add_argument('--author', '-a', default=author, required=not author,
                         help='User name to write the Copyright lines')
-    parser.add_argument('--email', default=email, required=not email,
+    parser.add_argument('--email', '-e', default=email, required=not email,
                         help='Email address to write the Copyright lines')
     opts = parser.parse_args()
 
     if not opts.author or not opts.email:
         parser.error('Please provide your username and email address, '
-                     'or set your git configuration up.') 
-    name = opts.name
+                     'or set your git configuration up.')
+    name = ' '.join(opts.name)
+    if not name:
+        parser.error('Please provide a driver name.')
     names = {
         'name': name,
         'short': re.sub('[^a-z0-9]', '-', name.lower()),