public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Michael Frysinger <vapier@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] gdb: make copyright.py interface a bit nicer
Date: Wed, 26 Oct 2022 10:09:52 +0000 (GMT)	[thread overview]
Message-ID: <20221026100952.BF45D3858030@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e5fbca55b28b77eced290e4e681f1d5cd3dafe98

commit e5fbca55b28b77eced290e4e681f1d5cd3dafe98
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Sat Jan 1 13:02:02 2022 -0500

    gdb: make copyright.py interface a bit nicer
    
    This way people can run `./copyright.py --help` and get some info as
    to what this does without it going and modifying the tree.

Diff:
---
 gdb/copyright.py | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/gdb/copyright.py b/gdb/copyright.py
old mode 100644
new mode 100755
index 48192e80560..8d623e6f5c7
--- a/gdb/copyright.py
+++ b/gdb/copyright.py
@@ -22,7 +22,7 @@
 This script updates the list of years in the copyright notices in
 most files maintained by the GDB project.
 
-Usage: cd src/gdb && python copyright.py
+Usage: cd src/gdb && ./copyright.py
 
 Always review the output of this script before committing it!
 A useful command to review the output is:
@@ -30,12 +30,14 @@ A useful command to review the output is:
 This removes the bulk of the changes which are most likely to be correct.
 """
 
+import argparse
 import datetime
 import locale
 import os
 import os.path
 import subprocess
 import sys
+from typing import List, Optional
 
 
 def get_update_list():
@@ -158,16 +160,25 @@ def may_have_copyright_notice(filename):
     return False
 
 
-def main():
+def get_parser() -> argparse.ArgumentParser:
+    """Get a command line parser."""
+    parser = argparse.ArgumentParser(
+        description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
+    )
+    return parser
+
+
+def main(argv: List[str]) -> Optional[int]:
     """The main subprogram."""
+    parser = get_parser()
+    _ = parser.parse_args(argv)
     root_dir = os.path.dirname(os.getcwd())
     os.chdir(root_dir)
 
     if not (
         os.path.isdir("gdb") and os.path.isfile("gnulib/import/extra/update-copyright")
     ):
-        print("Error: This script must be called from the gdb directory.")
-        sys.exit(1)
+        sys.exit("Error: This script must be called from the gdb directory.")
 
     update_list = get_update_list()
     update_files(update_list)
@@ -416,4 +427,4 @@ NOT_FSF_LIST = (
 )
 
 if __name__ == "__main__":
-    main()
+    sys.exit(main(sys.argv[1:]))

                 reply	other threads:[~2022-10-26 10:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221026100952.BF45D3858030@sourceware.org \
    --to=vapier@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).