]> sigrok.org Git - sigrok-util.git/commitdiff
new-driver: do accept multiple command line words for driver name
authorGerhard Sittig <redacted>
Sun, 21 May 2017 16:18:43 +0000 (18:18 +0200)
committerUwe Hermann <redacted>
Sun, 21 May 2017 16:29:14 +0000 (18:29 +0200)
The README specifies that driver names consist of multiple words
(typically vendor and model). Adjust the args parser configuration such
that more than one word gets accepted (the previous implementation did
insist on a single word).

source/new-driver

index 61a3960877489c259519d11b838afa9a55b677f5..14178d3241dfb5849abe4886aff646601444f6d1 100755 (executable)
@@ -178,7 +178,7 @@ if __name__ == '__main__':
     author, email = parse_gitconfig()
 
     parser = ArgumentParser(description='Bootstrap a new sigrok hardware driver')
     author, email = parse_gitconfig()
 
     parser = ArgumentParser(description='Bootstrap a new sigrok hardware driver')
-    parser.add_argument('name', help='new driver name')
+    parser.add_argument('name', nargs='*', default=[], help='new driver name')
     parser.add_argument('--giturl', default=defaulturl,
                         help='URL of the libsigrok git repository '
                         '(defaults to {0})'.format(defaulturl))
     parser.add_argument('--giturl', default=defaulturl,
                         help='URL of the libsigrok git repository '
                         '(defaults to {0})'.format(defaulturl))
@@ -194,7 +194,9 @@ if __name__ == '__main__':
     if not opts.author or not opts.email:
         parser.error('Please provide your username and email address, '
                      'or set your git configuration up.')
     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
+    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()),
     names = {
         'name': name,
         'short': re.sub('[^a-z0-9]', '-', name.lower()),