diff mbox

list-fixed-bugs: use argparse for the commandline

Message ID 1447134325-895-1-git-send-email-vapier@gentoo.org
State New
Headers show

Commit Message

Mike Frysinger Nov. 10, 2015, 5:45 a.m. UTC
This makes the interface more friendly to users.

2015-11-09  Mike Frysinger  <vapier@gentoo.org>

	* scripts/list-fixed-bugs.py: Import argparse.  Call main instead.
	(get_parser): New function.
	(main): New function.
---
 scripts/list-fixed-bugs.py | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

Comments

Mike Frysinger Dec. 29, 2015, 4:58 p.m. UTC | #1
On 10 Nov 2015 00:45, Mike Frysinger wrote:
> This makes the interface more friendly to users.

ping
-mike
Florian Weimer Dec. 29, 2015, 5:28 p.m. UTC | #2
On 11/10/2015 06:45 AM, Mike Frysinger wrote:
> This makes the interface more friendly to users.
> 
> 2015-11-09  Mike Frysinger  <vapier@gentoo.org>
> 
> 	* scripts/list-fixed-bugs.py: Import argparse.  Call main instead.
> 	(get_parser): New function.
> 	(main): New function.

Looks okay.

Florian
diff mbox

Patch

diff --git a/scripts/list-fixed-bugs.py b/scripts/list-fixed-bugs.py
index 37e9a43..0a61adc 100755
--- a/scripts/list-fixed-bugs.py
+++ b/scripts/list-fixed-bugs.py
@@ -23,11 +23,21 @@  bugs marked as FIXED with that milestone, to be added to the NEWS file
 just before release.  The output is in UTF-8.
 """
 
+import argparse
 import json
 import sys
 import textwrap
 import urllib.request
 
+
+def get_parser():
+    """Return an argument parser for this module."""
+    parser = argparse.ArgumentParser(description=__doc__)
+    parser.add_argument('version',
+                        help='Release version to look up')
+    return parser
+
+
 def list_fixed_bugs(version):
     """List the bugs fixed in a given version."""
     url = ('https://sourceware.org/bugzilla/rest.cgi/bug?product=glibc'
@@ -42,5 +52,13 @@  def list_fixed_bugs(version):
                              subsequent_indent='    ') + '\n'
         sys.stdout.buffer.write(desc.encode('utf-8'))
 
+
+def main(argv):
+    """The main entry point."""
+    parser = get_parser()
+    opts = parser.parse_args(argv)
+    list_fixed_bugs(opts.version)
+
+
 if __name__ == '__main__':
-    list_fixed_bugs(sys.argv[1])
+    main(sys.argv[1:])