scripts: Added -Q/--query as alternative to --total

This better matches the runners' new -Q/--query-define flag, and, thanks
to some argparse trickery, is simpler implementation wise.

Example:

  $ ./scripts/code.py lfs3.o -Qsize
      66570

  $ ./scripts/stack.py -Qlimit lfs3.ci
       3312

The only downside is this takes the --small-table shortform flag, but
--small-table doesn't really need a shortform flag.
This commit is contained in:
Christopher Haster
2026-02-12 19:13:53 -06:00
parent cb91b6b2a6
commit 93c85870e8
10 changed files with 257 additions and 154 deletions
+1 -1
View File
@@ -486,7 +486,7 @@ summary-diff sizes-diff: $(OBJ) $(CI)
-fstack='max(stack_limit)' \ -fstack='max(stack_limit)' \
-fctx='max(ctx_size)' \ -fctx='max(ctx_size)' \
-o-) \ -o-) \
-bbuild -CBEFORE -Q $(SUMMARYFLAGS)) -bbuild -CBEFORE --small-table $(SUMMARYFLAGS))
## Generate a codemap svg ## Generate a codemap svg
+28 -17
View File
@@ -620,26 +620,14 @@ def table(Result, results, diff_results=None, *,
small_header=False, small_header=False,
no_total=False, no_total=False,
small_total=False, small_total=False,
small_table=False,
summary=False, summary=False,
total=False,
**_): **_):
import builtins import builtins
all_, all = all, builtins.all all_, all = all, builtins.all
# small_table implies small_header + no_total or small_total
if small_table:
small_header = True
small_total = True
no_total = no_total or (not summary and not total)
# summary implies small_header # summary implies small_header
if summary: if summary:
small_header = True small_header = True
# total implies summary + no_header + small_total
if total:
summary = True
no_header = True
small_total = True
if by is None: if by is None:
by = Result._by by = Result._by
@@ -1188,6 +1176,20 @@ if __name__ == "__main__":
action='append', action='append',
choices=CodeResult._fields, choices=CodeResult._fields,
help="Show this field.") help="Show this field.")
class AppendQuery(argparse.Action):
def __call__(self, parser, namespace, value, option):
if namespace.fields is None:
namespace.fields = []
namespace.fields.append(value)
namespace.summary = True
namespace.no_header = True
namespace.small_total = True
parser.add_argument(
'-Q', '--query',
action=AppendQuery,
choices=CodeResult._fields,
help="Like -f/--field, but also implies --total. Useful for "
"scripting.")
parser.add_argument( parser.add_argument(
'-D', '--define', '-D', '--define',
dest='defines', dest='defines',
@@ -1241,17 +1243,26 @@ if __name__ == "__main__":
'--small-total', '--small-total',
action='store_true', action='store_true',
help="Don't show TOTAL name.") help="Don't show TOTAL name.")
class StoreSmallTable(argparse._StoreTrueAction):
def __call__(self, parser, namespace, value, option):
namespace.small_header = True
namespace.no_total = True
parser.add_argument( parser.add_argument(
'-Q', '--small-table', '--small-table',
action='store_true', action=StoreSmallTable,
help="Equivalent to --small-header + --no-total or --small-total.") help="Equivalent to --small-header + --no-total.")
parser.add_argument( parser.add_argument(
'-Y', '--summary', '-Y', '--summary',
action='store_true', action='store_true',
help="Only show the total.") help="Only show the total.")
class StoreTotal(argparse._StoreTrueAction):
def __call__(self, parser, namespace, value, option):
namespace.summary = True
namespace.no_header = True
namespace.small_total = True
parser.add_argument( parser.add_argument(
'-t', '--total', '--total',
action='store_true', action=StoreTotal,
help="Equivalent to --summary + --no-header + --small-total. " help="Equivalent to --summary + --no-header + --small-total. "
"Useful for scripting.") "Useful for scripting.")
parser.add_argument( parser.add_argument(
+28 -17
View File
@@ -489,26 +489,14 @@ def table(Result, results, diff_results=None, *,
small_header=False, small_header=False,
no_total=False, no_total=False,
small_total=False, small_total=False,
small_table=False,
summary=False, summary=False,
total=False,
**_): **_):
import builtins import builtins
all_, all = all, builtins.all all_, all = all, builtins.all
# small_table implies small_header + no_total or small_total
if small_table:
small_header = True
small_total = True
no_total = no_total or (not summary and not total)
# summary implies small_header # summary implies small_header
if summary: if summary:
small_header = True small_header = True
# total implies summary + no_header + small_total
if total:
summary = True
no_header = True
small_total = True
if by is None: if by is None:
by = Result._by by = Result._by
@@ -1167,6 +1155,20 @@ if __name__ == "__main__":
action='append', action='append',
choices=CovResult._fields, choices=CovResult._fields,
help="Show this field.") help="Show this field.")
class AppendQuery(argparse.Action):
def __call__(self, parser, namespace, value, option):
if namespace.fields is None:
namespace.fields = []
namespace.fields.append(value)
namespace.summary = True
namespace.no_header = True
namespace.small_total = True
parser.add_argument(
'-Q', '--query',
action=AppendQuery,
choices=CovResult._fields,
help="Like -f/--field, but also implies --total. Useful for "
"scripting.")
parser.add_argument( parser.add_argument(
'-D', '--define', '-D', '--define',
dest='defines', dest='defines',
@@ -1220,17 +1222,26 @@ if __name__ == "__main__":
'--small-total', '--small-total',
action='store_true', action='store_true',
help="Don't show TOTAL name.") help="Don't show TOTAL name.")
class StoreSmallTable(argparse._StoreTrueAction):
def __call__(self, parser, namespace, value, option):
namespace.small_header = True
namespace.no_total = True
parser.add_argument( parser.add_argument(
'-Q', '--small-table', '--small-table',
action='store_true', action=StoreSmallTable,
help="Equivalent to --small-header + --no-total or --small-total.") help="Equivalent to --small-header + --no-total.")
parser.add_argument( parser.add_argument(
'-Y', '--summary', '-Y', '--summary',
action='store_true', action='store_true',
help="Only show the total.") help="Only show the total.")
class StoreTotal(argparse._StoreTrueAction):
def __call__(self, parser, namespace, value, option):
namespace.summary = True
namespace.no_header = True
namespace.small_total = True
parser.add_argument( parser.add_argument(
'-t', '--total', '--total',
action='store_true', action=StoreTotal,
help="Equivalent to --summary + --no-header + --small-total. " help="Equivalent to --summary + --no-header + --small-total. "
"Useful for scripting.") "Useful for scripting.")
parser.add_argument( parser.add_argument(
+32 -17
View File
@@ -2264,26 +2264,14 @@ def table(Result, results, diff_results=None, *,
small_header=False, small_header=False,
no_total=False, no_total=False,
small_total=False, small_total=False,
small_table=False,
summary=False, summary=False,
total=False,
**_): **_):
import builtins import builtins
all_, all = all, builtins.all all_, all = all, builtins.all
# small_table implies small_header + no_total or small_total
if small_table:
small_header = True
small_total = True
no_total = no_total or (not summary and not total)
# summary implies small_header # summary implies small_header
if summary: if summary:
small_header = True small_header = True
# total implies summary + no_header + small_total
if total:
summary = True
no_header = True
small_total = True
if by is None: if by is None:
by = Result._by by = Result._by
@@ -3326,6 +3314,24 @@ if __name__ == "__main__":
)(*x.split('=', 1)), )(*x.split('=', 1)),
help="Like -f/--field, but hidden from the table renderer, " help="Like -f/--field, but hidden from the table renderer, "
"and doesn't affect -f/--field defaults.") "and doesn't affect -f/--field defaults.")
class AppendQuery(argparse.Action):
def __call__(self, parser, namespace, value, option):
if namespace.fields is None:
namespace.fields = []
namespace.fields.append((value, False))
namespace.summary = True
namespace.no_header = True
namespace.small_total = True
parser.add_argument(
'-Q', '--query',
action=AppendQuery,
type=lambda x: (
lambda k, v=None: (
k.strip(),
CsvExpr(v) if v is not None else None)
)(*x.split('=', 1)),
help="Like -f/--field, but also implies --total. Useful for "
"scripting.")
parser.add_argument( parser.add_argument(
'-D', '--define', '-D', '--define',
dest='defines', dest='defines',
@@ -3458,17 +3464,26 @@ if __name__ == "__main__":
'--small-total', '--small-total',
action='store_true', action='store_true',
help="Don't show TOTAL name.") help="Don't show TOTAL name.")
class StoreSmallTable(argparse._StoreTrueAction):
def __call__(self, parser, namespace, value, option):
namespace.small_header = True
namespace.no_total = True
parser.add_argument( parser.add_argument(
'-Q', '--small-table', '--small-table',
action='store_true', action=StoreSmallTable,
help="Equivalent to --small-header + --no-total or --small-total.") help="Equivalent to --small-header + --no-total.")
parser.add_argument( parser.add_argument(
'-Y', '--summary', '-Y', '--summary',
action='store_true', action='store_true',
help="Only show the total.") help="Only show the total.")
class StoreTotal(argparse._StoreTrueAction):
def __call__(self, parser, namespace, value, option):
namespace.summary = True
namespace.no_header = True
namespace.small_total = True
parser.add_argument( parser.add_argument(
'-t', '--total', '--total',
action='store_true', action=StoreTotal,
help="Equivalent to --summary + --no-header + --small-total. " help="Equivalent to --summary + --no-header + --small-total. "
"Useful for scripting.") "Useful for scripting.")
parser.add_argument( parser.add_argument(
+28 -17
View File
@@ -879,26 +879,14 @@ def table(Result, results, diff_results=None, *,
small_header=False, small_header=False,
no_total=False, no_total=False,
small_total=False, small_total=False,
small_table=False,
summary=False, summary=False,
total=False,
**_): **_):
import builtins import builtins
all_, all = all, builtins.all all_, all = all, builtins.all
# small_table implies small_header + no_total or small_total
if small_table:
small_header = True
small_total = True
no_total = no_total or (not summary and not total)
# summary implies small_header # summary implies small_header
if summary: if summary:
small_header = True small_header = True
# total implies summary + no_header + small_total
if total:
summary = True
no_header = True
small_total = True
if by is None: if by is None:
by = Result._by by = Result._by
@@ -1483,6 +1471,20 @@ if __name__ == "__main__":
action='append', action='append',
choices=CtxResult._fields, choices=CtxResult._fields,
help="Show this field.") help="Show this field.")
class AppendQuery(argparse.Action):
def __call__(self, parser, namespace, value, option):
if namespace.fields is None:
namespace.fields = []
namespace.fields.append(value)
namespace.summary = True
namespace.no_header = True
namespace.small_total = True
parser.add_argument(
'-Q', '--query',
action=AppendQuery,
choices=CtxResult._fields,
help="Like -f/--field, but also implies --total. Useful for "
"scripting.")
parser.add_argument( parser.add_argument(
'-D', '--define', '-D', '--define',
dest='defines', dest='defines',
@@ -1559,17 +1561,26 @@ if __name__ == "__main__":
'--small-total', '--small-total',
action='store_true', action='store_true',
help="Don't show TOTAL name.") help="Don't show TOTAL name.")
class StoreSmallTable(argparse._StoreTrueAction):
def __call__(self, parser, namespace, value, option):
namespace.small_header = True
namespace.no_total = True
parser.add_argument( parser.add_argument(
'-Q', '--small-table', '--small-table',
action='store_true', action=StoreSmallTable,
help="Equivalent to --small-header + --no-total or --small-total.") help="Equivalent to --small-header + --no-total.")
parser.add_argument( parser.add_argument(
'-Y', '--summary', '-Y', '--summary',
action='store_true', action='store_true',
help="Only show the total.") help="Only show the total.")
class StoreTotal(argparse._StoreTrueAction):
def __call__(self, parser, namespace, value, option):
namespace.summary = True
namespace.no_header = True
namespace.small_total = True
parser.add_argument( parser.add_argument(
'-t', '--total', '--total',
action='store_true', action=StoreTotal,
help="Equivalent to --summary + --no-header + --small-total. " help="Equivalent to --summary + --no-header + --small-total. "
"Useful for scripting.") "Useful for scripting.")
parser.add_argument( parser.add_argument(
+28 -17
View File
@@ -620,26 +620,14 @@ def table(Result, results, diff_results=None, *,
small_header=False, small_header=False,
no_total=False, no_total=False,
small_total=False, small_total=False,
small_table=False,
summary=False, summary=False,
total=False,
**_): **_):
import builtins import builtins
all_, all = all, builtins.all all_, all = all, builtins.all
# small_table implies small_header + no_total or small_total
if small_table:
small_header = True
small_total = True
no_total = no_total or (not summary and not total)
# summary implies small_header # summary implies small_header
if summary: if summary:
small_header = True small_header = True
# total implies summary + no_header + small_total
if total:
summary = True
no_header = True
small_total = True
if by is None: if by is None:
by = Result._by by = Result._by
@@ -1188,6 +1176,20 @@ if __name__ == "__main__":
action='append', action='append',
choices=DataResult._fields, choices=DataResult._fields,
help="Show this field.") help="Show this field.")
class AppendQuery(argparse.Action):
def __call__(self, parser, namespace, value, option):
if namespace.fields is None:
namespace.fields = []
namespace.fields.append(value)
namespace.summary = True
namespace.no_header = True
namespace.small_total = True
parser.add_argument(
'-Q', '--query',
action=AppendQuery,
choices=DataResult._fields,
help="Like -f/--field, but also implies --total. Useful for "
"scripting.")
parser.add_argument( parser.add_argument(
'-D', '--define', '-D', '--define',
dest='defines', dest='defines',
@@ -1241,17 +1243,26 @@ if __name__ == "__main__":
'--small-total', '--small-total',
action='store_true', action='store_true',
help="Don't show TOTAL name.") help="Don't show TOTAL name.")
class StoreSmallTable(argparse._StoreTrueAction):
def __call__(self, parser, namespace, value, option):
namespace.small_header = True
namespace.no_total = True
parser.add_argument( parser.add_argument(
'-Q', '--small-table', '--small-table',
action='store_true', action=StoreSmallTable,
help="Equivalent to --small-header + --no-total or --small-total.") help="Equivalent to --small-header + --no-total.")
parser.add_argument( parser.add_argument(
'-Y', '--summary', '-Y', '--summary',
action='store_true', action='store_true',
help="Only show the total.") help="Only show the total.")
class StoreTotal(argparse._StoreTrueAction):
def __call__(self, parser, namespace, value, option):
namespace.summary = True
namespace.no_header = True
namespace.small_total = True
parser.add_argument( parser.add_argument(
'-t', '--total', '--total',
action='store_true', action=StoreTotal,
help="Equivalent to --summary + --no-header + --small-total. " help="Equivalent to --summary + --no-header + --small-total. "
"Useful for scripting.") "Useful for scripting.")
parser.add_argument( parser.add_argument(
+28 -17
View File
@@ -978,26 +978,14 @@ def table(Result, results, diff_results=None, *,
small_header=False, small_header=False,
no_total=False, no_total=False,
small_total=False, small_total=False,
small_table=False,
summary=False, summary=False,
total=False,
**_): **_):
import builtins import builtins
all_, all = all, builtins.all all_, all = all, builtins.all
# small_table implies small_header + no_total or small_total
if small_table:
small_header = True
small_total = True
no_total = no_total or (not summary and not total)
# summary implies small_header # summary implies small_header
if summary: if summary:
small_header = True small_header = True
# total implies summary + no_header + small_total
if total:
summary = True
no_header = True
small_total = True
if by is None: if by is None:
by = Result._by by = Result._by
@@ -1728,6 +1716,20 @@ if __name__ == "__main__":
action='append', action='append',
choices=PerfResult._fields, choices=PerfResult._fields,
help="Show this field.") help="Show this field.")
class AppendQuery(argparse.Action):
def __call__(self, parser, namespace, value, option):
if namespace.fields is None:
namespace.fields = []
namespace.fields.append(value)
namespace.summary = True
namespace.no_header = True
namespace.small_total = True
parser.add_argument(
'-Q', '--query',
action=AppendQuery,
choices=PerfResult._fields,
help="Like -f/--field, but also implies --total. Useful for "
"scripting.")
parser.add_argument( parser.add_argument(
'-D', '--define', '-D', '--define',
dest='defines', dest='defines',
@@ -1809,17 +1811,26 @@ if __name__ == "__main__":
'--small-total', '--small-total',
action='store_true', action='store_true',
help="Don't show TOTAL name.") help="Don't show TOTAL name.")
class StoreSmallTable(argparse._StoreTrueAction):
def __call__(self, parser, namespace, value, option):
namespace.small_header = True
namespace.no_total = True
parser.add_argument( parser.add_argument(
'-Q', '--small-table', '--small-table',
action='store_true', action=StoreSmallTable,
help="Equivalent to --small-header + --no-total or --small-total.") help="Equivalent to --small-header + --no-total.")
parser.add_argument( parser.add_argument(
'-Y', '--summary', '-Y', '--summary',
action='store_true', action='store_true',
help="Only show the total.") help="Only show the total.")
class StoreTotal(argparse._StoreTrueAction):
def __call__(self, parser, namespace, value, option):
namespace.summary = True
namespace.no_header = True
namespace.small_total = True
parser.add_argument( parser.add_argument(
'-t', '--total', '--total',
action='store_true', action=StoreTotal,
help="Equivalent to --summary + --no-header + --small-total. " help="Equivalent to --summary + --no-header + --small-total. "
"Useful for scripting.") "Useful for scripting.")
parser.add_argument( parser.add_argument(
+28 -17
View File
@@ -952,26 +952,14 @@ def table(Result, results, diff_results=None, *,
small_header=False, small_header=False,
no_total=False, no_total=False,
small_total=False, small_total=False,
small_table=False,
summary=False, summary=False,
total=False,
**_): **_):
import builtins import builtins
all_, all = all, builtins.all all_, all = all, builtins.all
# small_table implies small_header + no_total or small_total
if small_table:
small_header = True
small_total = True
no_total = no_total or (not summary and not total)
# summary implies small_header # summary implies small_header
if summary: if summary:
small_header = True small_header = True
# total implies summary + no_header + small_total
if total:
summary = True
no_header = True
small_total = True
if by is None: if by is None:
by = Result._by by = Result._by
@@ -1728,6 +1716,20 @@ if __name__ == "__main__":
action='append', action='append',
choices=PerfBdResult._fields, choices=PerfBdResult._fields,
help="Show this field.") help="Show this field.")
class AppendQuery(argparse.Action):
def __call__(self, parser, namespace, value, option):
if namespace.fields is None:
namespace.fields = []
namespace.fields.append(value)
namespace.summary = True
namespace.no_header = True
namespace.small_total = True
parser.add_argument(
'-Q', '--query',
action=AppendQuery,
choices=PerfBdResult._fields,
help="Like -f/--field, but also implies --total. Useful for "
"scripting.")
parser.add_argument( parser.add_argument(
'-D', '--define', '-D', '--define',
dest='defines', dest='defines',
@@ -1809,17 +1811,26 @@ if __name__ == "__main__":
'--small-total', '--small-total',
action='store_true', action='store_true',
help="Don't show TOTAL name.") help="Don't show TOTAL name.")
class StoreSmallTable(argparse._StoreTrueAction):
def __call__(self, parser, namespace, value, option):
namespace.small_header = True
namespace.no_total = True
parser.add_argument( parser.add_argument(
'-Q', '--small-table', '--small-table',
action='store_true', action=StoreSmallTable,
help="Equivalent to --small-header + --no-total or --small-total.") help="Equivalent to --small-header + --no-total.")
parser.add_argument( parser.add_argument(
'-Y', '--summary', '-Y', '--summary',
action='store_true', action='store_true',
help="Only show the total.") help="Only show the total.")
class StoreTotal(argparse._StoreTrueAction):
def __call__(self, parser, namespace, value, option):
namespace.summary = True
namespace.no_header = True
namespace.small_total = True
parser.add_argument( parser.add_argument(
'-t', '--total', '--total',
action='store_true', action=StoreTotal,
help="Equivalent to --summary + --no-header + --small-total. " help="Equivalent to --summary + --no-header + --small-total. "
"Useful for scripting.") "Useful for scripting.")
parser.add_argument( parser.add_argument(
+28 -17
View File
@@ -620,26 +620,14 @@ def table(Result, results, diff_results=None, *,
small_header=False, small_header=False,
no_total=False, no_total=False,
small_total=False, small_total=False,
small_table=False,
summary=False, summary=False,
total=False,
**_): **_):
import builtins import builtins
all_, all = all, builtins.all all_, all = all, builtins.all
# small_table implies small_header + no_total or small_total
if small_table:
small_header = True
small_total = True
no_total = no_total or (not summary and not total)
# summary implies small_header # summary implies small_header
if summary: if summary:
small_header = True small_header = True
# total implies summary + no_header + small_total
if total:
summary = True
no_header = True
small_total = True
if by is None: if by is None:
by = Result._by by = Result._by
@@ -1226,6 +1214,20 @@ if __name__ == "__main__":
action='append', action='append',
choices=StackResult._fields, choices=StackResult._fields,
help="Show this field.") help="Show this field.")
class AppendQuery(argparse.Action):
def __call__(self, parser, namespace, value, option):
if namespace.fields is None:
namespace.fields = []
namespace.fields.append(value)
namespace.summary = True
namespace.no_header = True
namespace.small_total = True
parser.add_argument(
'-Q', '--query',
action=AppendQuery,
choices=StackResult._fields,
help="Like -f/--field, but also implies --total. Useful for "
"scripting.")
parser.add_argument( parser.add_argument(
'-D', '--define', '-D', '--define',
dest='defines', dest='defines',
@@ -1302,17 +1304,26 @@ if __name__ == "__main__":
'--small-total', '--small-total',
action='store_true', action='store_true',
help="Don't show TOTAL name.") help="Don't show TOTAL name.")
class StoreSmallTable(argparse._StoreTrueAction):
def __call__(self, parser, namespace, value, option):
namespace.small_header = True
namespace.no_total = True
parser.add_argument( parser.add_argument(
'-Q', '--small-table', '--small-table',
action='store_true', action=StoreSmallTable,
help="Equivalent to --small-header + --no-total or --small-total.") help="Equivalent to --small-header + --no-total.")
parser.add_argument( parser.add_argument(
'-Y', '--summary', '-Y', '--summary',
action='store_true', action='store_true',
help="Only show the total.") help="Only show the total.")
class StoreTotal(argparse._StoreTrueAction):
def __call__(self, parser, namespace, value, option):
namespace.summary = True
namespace.no_header = True
namespace.small_total = True
parser.add_argument( parser.add_argument(
'-t', '--total', '--total',
action='store_true', action=StoreTotal,
help="Equivalent to --summary + --no-header + --small-total. " help="Equivalent to --summary + --no-header + --small-total. "
"Useful for scripting.") "Useful for scripting.")
parser.add_argument( parser.add_argument(
+28 -17
View File
@@ -768,26 +768,14 @@ def table(Result, results, diff_results=None, *,
small_header=False, small_header=False,
no_total=False, no_total=False,
small_total=False, small_total=False,
small_table=False,
summary=False, summary=False,
total=False,
**_): **_):
import builtins import builtins
all_, all = all, builtins.all all_, all = all, builtins.all
# small_table implies small_header + no_total or small_total
if small_table:
small_header = True
small_total = True
no_total = no_total or (not summary and not total)
# summary implies small_header # summary implies small_header
if summary: if summary:
small_header = True small_header = True
# total implies summary + no_header + small_total
if total:
summary = True
no_header = True
small_total = True
if by is None: if by is None:
by = Result._by by = Result._by
@@ -1372,6 +1360,20 @@ if __name__ == "__main__":
action='append', action='append',
choices=StructResult._fields, choices=StructResult._fields,
help="Show this field.") help="Show this field.")
class AppendQuery(argparse.Action):
def __call__(self, parser, namespace, value, option):
if namespace.fields is None:
namespace.fields = []
namespace.fields.append(value)
namespace.summary = True
namespace.no_header = True
namespace.small_total = True
parser.add_argument(
'-Q', '--query',
action=AppendQuery,
choices=StructResult._fields,
help="Like -f/--field, but also implies --total. Useful for "
"scripting.")
parser.add_argument( parser.add_argument(
'-D', '--define', '-D', '--define',
dest='defines', dest='defines',
@@ -1448,17 +1450,26 @@ if __name__ == "__main__":
'--small-total', '--small-total',
action='store_true', action='store_true',
help="Don't show TOTAL name.") help="Don't show TOTAL name.")
class StoreSmallTable(argparse._StoreTrueAction):
def __call__(self, parser, namespace, value, option):
namespace.small_header = True
namespace.no_total = True
parser.add_argument( parser.add_argument(
'-Q', '--small-table', '--small-table',
action='store_true', action=StoreSmallTable,
help="Equivalent to --small-header + --no-total or --small-total.") help="Equivalent to --small-header + --no-total.")
parser.add_argument( parser.add_argument(
'-Y', '--summary', '-Y', '--summary',
action='store_true', action='store_true',
help="Only show the total.") help="Only show the total.")
class StoreTotal(argparse._StoreTrueAction):
def __call__(self, parser, namespace, value, option):
namespace.summary = True
namespace.no_header = True
namespace.small_total = True
parser.add_argument( parser.add_argument(
'-t', '--total', '--total',
action='store_true', action=StoreTotal,
help="Equivalent to --summary + --no-header + --small-total. " help="Equivalent to --summary + --no-header + --small-total. "
"Useful for scripting.") "Useful for scripting.")
parser.add_argument( parser.add_argument(