"""Parse command line arguments and return an argparse Namespace object."""
parser=argparse.ArgumentParser(description="Compile a TraceFile.proto from a manual text file.")
# argparse considers args starting with - and -- optional in --help, even though required=True.
# by using a named argument group --help will clearly say that it's required instead of optional.
required_named=parser.add_argument_group('required named arguments')
# optional arguments
# use a group here to get the required arguments to appear 'above' the optional arguments in help.
optional_named=parser.add_argument_group('optional named arguments')
optional_named.add_argument('-opb','--output-proto-binary',dest='output_proto_binary',action='store',help='Write binary proto output to file.')
optional_named.add_argument('-pm','--pinlist-meta',dest='pinlist_meta',action='store',help='Path to pinlist.meta (default=none) binary file.')
optional_named.add_argument('-pmp','--pinlist-meta-parent',dest='pinlist_meta_parent',action='store',help='Device path that the pinlist.meta applies to (e.g. /data/.../somefile.apk)')
optional_named.add_argument('-i','--input',dest='input',action='store',help='Input text file (default stdin).')
optional_named.add_argument('-zp','--zip_path',dest='zip_path',action='append',help='Directory containing zip files.')
optional_named.add_argument('-d','--debug',dest='debug',action='store_true',help='Add extra debugging output')
optional_named.add_argument('-ot','--output-text',dest='output_text',action='store',help='Output text file (default stdout).')
returnparser.parse_args(argv)
# TODO: refactor this with a common library file with analyze_metrics.py
def_debug_print(*args,**kwargs):
"""Print the args to sys.stderr if the --debug/-d flag was passed in."""