>From 56a625b004c134b41a92fc658871df2f954fcafe Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 31 Jul 2022 18:48:25 +0200 Subject: [PATCH 06/16] gnulib-tool.py: Improve compliance with GNU standards. * gnulib-tool.py (main): Handle --help and --version before testing for conflicting modes. --- ChangeLog | 4 ++++ gnulib-tool.py | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3c271bd4de..f5b9c4e968 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2022-07-31 Bruno Haible + gnulib-tool.py: Improve compliance with GNU standards. + * gnulib-tool.py (main): Handle --help and --version before testing for + conflicting modes. + gnulib-tool.py: Emit error message when conflicting modes are specified. * gnulib-tool.py (main): Fix test of conflicting modes. (Some options produce a value of [], and as a condition, [] evaluates to False.) diff --git a/gnulib-tool.py b/gnulib-tool.py index b16becb1d2..a6d4f6fa75 100755 --- a/gnulib-tool.py +++ b/gnulib-tool.py @@ -340,6 +340,17 @@ def main(): # Parse the given arguments. cmdargs = parser.parse_args() + # Handle --help and --version, ignoring all other options. + if cmdargs.help != None: + print(info.usage()) + sys.exit(0) + if cmdargs.version != None: + message = '''gnulib-tool (%s %s)%s\n%s\n%s\n\nWritten by %s.''' % \ + (info.package(), info.date(), info.version(), info.copyright(), + info.license(), info.authors()) + print(message) + sys.exit(0) + # Determine when user tries to combine modes. args = [ cmdargs.mode_list, @@ -374,15 +385,6 @@ def main(): sys.exit(1) # Determine selected mode. - if cmdargs.help != None: - print(info.usage()) - sys.exit(0) - if cmdargs.version != None: - message = '''gnulib-tool (%s %s)%s\n%s\n%s\n\nWritten by %s.''' % \ - (info.package(), info.date(), info.version(), info.copyright(), - info.license(), info.authors()) - print(message) - sys.exit(0) if cmdargs.mode_list != None: mode = 'list' if cmdargs.mode_import != None: -- 2.34.1