From b113ca4819ad710bbfcdd44f3489eacaa5a95128 Mon Sep 17 00:00:00 2001 From: Moritz Schlarb Date: Thu, 24 May 2018 14:51:25 +0200 Subject: [PATCH] Use argparse in searpc-codegen for basic --help --- lib/searpc-codegen.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/searpc-codegen.py b/lib/searpc-codegen.py index acee024..b510025 100644 --- a/lib/searpc-codegen.py +++ b/lib/searpc-codegen.py @@ -176,11 +176,16 @@ def gen_signature_list(): write_file(f, generate_signature(item[0], item[1])) if __name__ == "__main__": + import argparse + parser = argparse.ArgumentParser(description='Generate function signatures and marshals for using Searpc') + parser.add_argument('rpc_mod_file', nargs='?', help='the RPC module file name (default: rpc_table)') + args = parser.parse_args() + sys.path.append(os.getcwd()) # load function table - if len(sys.argv) == 2: - abspath = os.path.abspath(sys.argv[1]) + if args.rpc_mod_file: + abspath = os.path.abspath(args.rpc_mod_file) with open(abspath, 'r') as fp: exec(fp.read()) print("loaded func_table from %s" % abspath)