summaryrefslogtreecommitdiffstats
path: root/Tools/c-analyzer/cpython/__main__.py
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/c-analyzer/cpython/__main__.py')
-rw-r--r--Tools/c-analyzer/cpython/__main__.py36
1 files changed, 31 insertions, 5 deletions
diff --git a/Tools/c-analyzer/cpython/__main__.py b/Tools/c-analyzer/cpython/__main__.py
index 9d29b13..a11b687 100644
--- a/Tools/c-analyzer/cpython/__main__.py
+++ b/Tools/c-analyzer/cpython/__main__.py
@@ -241,7 +241,7 @@ def _cli_capi(parser):
for raw in args.kinds or ():
for kind in raw.replace(',', ' ').strip().split():
if kind in _capi.KINDS:
- kind.append(kind)
+ kinds.append(kind)
else:
parser.error(f'expected KIND to be one of {sorted(_capi.KINDS)}, got {kind!r}')
args.kinds = set(kinds)
@@ -249,7 +249,7 @@ def _cli_capi(parser):
parser.add_argument('--group-by', dest='groupby',
choices=['level', 'kind'])
- parser.add_argument('--format', default='brief')
+ parser.add_argument('--format', default='table')
parser.add_argument('--summary', dest='format',
action='store_const', const='summary')
def process_format(args, *, argv=None):
@@ -259,12 +259,27 @@ def _cli_capi(parser):
if args.format not in _capi._FORMATS:
parser.error(f'unsupported format {orig!r}')
+ parser.add_argument('--show-empty', dest='showempty', action='store_true')
+ parser.add_argument('--no-show-empty', dest='showempty', action='store_false')
+ parser.set_defaults(showempty=None)
+
+ # XXX Add --sort-by, --sort and --no-sort.
+
+ parser.add_argument('--ignore', dest='ignored', action='append')
+ def process_ignored(args, *, argv=None):
+ ignored = []
+ for raw in args.ignored or ():
+ ignored.extend(raw.replace(',', ' ').strip().split())
+ args.ignored = ignored or None
+
parser.add_argument('filenames', nargs='*', metavar='FILENAME')
process_progress = add_progress_cli(parser)
return [
process_levels,
+ process_kinds,
process_format,
+ process_ignored,
process_progress,
]
@@ -273,7 +288,9 @@ def cmd_capi(filenames=None, *,
levels=None,
kinds=None,
groupby='kind',
- format='brief',
+ format='table',
+ showempty=None,
+ ignored=None,
track_progress=None,
verbosity=VERBOSITY,
**kwargs
@@ -282,7 +299,7 @@ def cmd_capi(filenames=None, *,
filenames = _files.iter_header_files(filenames, levels=levels)
#filenames = (file for file, _ in main_for_filenames(filenames))
- if track_progress is not None:
+ if track_progress:
filenames = track_progress(filenames)
items = _capi.iter_capi(filenames)
if levels:
@@ -290,7 +307,16 @@ def cmd_capi(filenames=None, *,
if kinds:
items = (item for item in items if item.kind in kinds)
- lines = render(items, groupby=groupby, verbose=verbosity > VERBOSITY)
+ filter = _capi.resolve_filter(ignored)
+ if filter:
+ items = (item for item in items if filter(item, log=lambda msg: logger.log(1, msg)))
+
+ lines = render(
+ items,
+ groupby=groupby,
+ showempty=showempty,
+ verbose=verbosity > VERBOSITY,
+ )
print()
for line in lines:
print(line)