from argparse import ArgumentParser
p = ArgumentParser()
p.add_argument('-b', '--body', help='Return USN records in comma-separated format', action='store_true')
p.add_argument('-c', '--csv', help='Return USN records in comma-separated format', action='store_true')
p.add_argument('-f', '--file', help='Parse the given USN journal file', required=True)
p.add_argument('-o', '--outfile', help='Parse the given USN journal file', required=True)
p.add_argument('-s', '--system', help='System name (use with -t)')
p.add_argument('-t', '--tln', help='TLN ou2tput (use with -s)', action='store_true')
p.add_argument('-v', '--verbose', help='Return all USN properties for each record (JSON)', action='store_true')
args = p.parse_args()
journalSize = os.path.getsize(args.file)
with open(args.file, 'rb') as i:
with open(args.outfile, 'wb') as o:
i.seek(findFirstRecord(i))
if args.csv:
do something
使用标准库的参数分析模块, 以属性的方式, 拿到具体的参数.