From 0c85f85904010e8ddf9653d16857a94ec40c1e7f Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Mon, 27 Jan 2020 23:30:40 +0100 Subject: use argparse version action to print allocbench version --- bench.py | 7 ++----- merge.py | 7 ++----- summarize.py | 7 ++----- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/bench.py b/bench.py index 35a6b76..a10fe77 100755 --- a/bench.py +++ b/bench.py @@ -111,16 +111,13 @@ def main(): action='store_true') parser.add_argument("--version", help="print version info and exit", - action='store_true') + action='version', + version=f"allocbench {src.facter.allocbench_version()}") args = parser.parse_args() if args.license: print_license_and_exit() - if args.version: - print(src.facter.allocbench_version()) - sys.exit(0) - atexit.register(epilog) # Set global verbosity diff --git a/merge.py b/merge.py index 3c88139..89bc7a4 100755 --- a/merge.py +++ b/merge.py @@ -41,15 +41,12 @@ def main(): if "--license" in sys.argv: print_license_and_exit() - if "--version" in sys.argv: - print(src.facter.allocbench_version()) - sys.exit(0) - parser = argparse.ArgumentParser(description="Merge to allocbench results") parser.add_argument("src", help="results which should be merged into dest", type=str) parser.add_argument("dest", help="results in which src should be merged", type=str) parser.add_argument("--license", help="print license info and exit", action='store_true') - parser.add_argument("--version", help="print version info and exit", action='store_true') + parser.add_argument("--version", help="print version info and exit", action='version', + version=f"allocbench {src.facter.allocbench_version()}") parser.add_argument("-b", "--benchmarks", help="benchmarks to summarize", nargs='+') parser.add_argument("-x", "--exclude-benchmarks", help="benchmarks to exclude", nargs='+') diff --git a/summarize.py b/summarize.py index 6bb0485..9d3f1b0 100755 --- a/summarize.py +++ b/summarize.py @@ -136,10 +136,6 @@ if __name__ == "__main__": if "--license" in sys.argv: print_license_and_exit() - if "--version" in sys.argv: - print(src.facter.allocbench_version()) - sys.exit(0) - parser = argparse.ArgumentParser( description="Summarize allocbench results in allocator sets") parser.add_argument("results", help="path to results", type=str) @@ -152,7 +148,8 @@ if __name__ == "__main__": action='store_true') parser.add_argument("--version", help="print version info and exit", - action='store_true') + action='version', + version=f"allocbench {src.facter.allocbench_version()}") parser.add_argument("-b", "--benchmarks", help="benchmarks to summarize", -- cgit v1.2.3