diff options
Diffstat (limited to 'dlopen-notes.py')
-rwxr-xr-x | dlopen-notes.py | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/dlopen-notes.py b/dlopen-notes.py index 29ea270..7d1f4ec 100755 --- a/dlopen-notes.py +++ b/dlopen-notes.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: CC0-1.0 """\ -Read .note.dlopen notes from ELF files and report the contents +Read .note.dlopen notes from ELF files and report the contents. """ import argparse @@ -118,23 +118,43 @@ def group_by_feature(filenames, notes): return features -def parse_args(): - p = argparse.ArgumentParser(description=__doc__) - p.add_argument('--raw', +def make_parser(): + p = argparse.ArgumentParser( + description=__doc__, + allow_abbrev=False, + add_help=False, + epilog='If no option is specifed, --raw is the default.', + ) + p.add_argument('-r', '--raw', action='store_true', - help='show the original JSON extracted from input files') - p.add_argument('--sonames', + help='Show the original JSON extracted from input files') + p.add_argument('-s', '--sonames', action='store_true', - help='list all sonames and their priorities, one soname per line') - p.add_argument('--features', + help='List all sonames and their priorities, one soname per line') + p.add_argument('-f', '--features', nargs='?', const=[], type=lambda s: s.split(','), action='extend', metavar='FEATURE1,FEATURE2', - help='describe features, can be specified multiple times') - p.add_argument('filenames', nargs='+', metavar='filename') - return p.parse_args() + help='Describe features, can be specified multiple times') + p.add_argument('filenames', + nargs='+', + metavar='filename', + help='Library file to extract notes from') + p.add_argument('-h', '--help', + action='help', + help='Show this help message and exit') + return p + +def parse_args(): + args = make_parser().parse_args() + + if not args.raw and args.features is None and not args.sonames: + # Make --raw the default if no action is specified. + args.raw = True + + return args if __name__ == '__main__': args = parse_args() |