From 4fe675af1cc8eb65f843e06962763dab8c920ce5 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Sun, 2 Dec 2018 22:42:14 +0700 Subject: Use argparse instead of manually parsing [skip ci] --- contrib/meson/GetLz4LibraryVersion.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/contrib/meson/GetLz4LibraryVersion.py b/contrib/meson/GetLz4LibraryVersion.py index e929f95..80b09c9 100644 --- a/contrib/meson/GetLz4LibraryVersion.py +++ b/contrib/meson/GetLz4LibraryVersion.py @@ -11,11 +11,6 @@ import re import sys -def usage(): - print('usage: python3 GetLz4LibraryVersion.py ') - sys.exit(1) - - def find_version(filepath): version_file_data = None with open(filepath) as fd: @@ -33,10 +28,11 @@ def find_version(filepath): def main(): - if len(sys.argv) < 2: - usage() - - filepath = sys.argv[1] + import argparse + parser = argparse.ArgumentParser(description='Print lz4 version from lib/lz4.h') + parser.add_argument('file', help='path to lib/lz4.h') + args = parser.parse_args() + filepath = args.file version_tup = find_version(filepath) print('.'.join(version_tup)) -- cgit v0.12