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:
+28
-17
@@ -620,26 +620,14 @@ def table(Result, results, diff_results=None, *,
|
||||
small_header=False,
|
||||
no_total=False,
|
||||
small_total=False,
|
||||
small_table=False,
|
||||
summary=False,
|
||||
total=False,
|
||||
**_):
|
||||
import builtins
|
||||
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
|
||||
if summary:
|
||||
small_header = True
|
||||
# total implies summary + no_header + small_total
|
||||
if total:
|
||||
summary = True
|
||||
no_header = True
|
||||
small_total = True
|
||||
|
||||
if by is None:
|
||||
by = Result._by
|
||||
@@ -1188,6 +1176,20 @@ if __name__ == "__main__":
|
||||
action='append',
|
||||
choices=CodeResult._fields,
|
||||
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(
|
||||
'-D', '--define',
|
||||
dest='defines',
|
||||
@@ -1241,17 +1243,26 @@ if __name__ == "__main__":
|
||||
'--small-total',
|
||||
action='store_true',
|
||||
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(
|
||||
'-Q', '--small-table',
|
||||
action='store_true',
|
||||
help="Equivalent to --small-header + --no-total or --small-total.")
|
||||
'--small-table',
|
||||
action=StoreSmallTable,
|
||||
help="Equivalent to --small-header + --no-total.")
|
||||
parser.add_argument(
|
||||
'-Y', '--summary',
|
||||
action='store_true',
|
||||
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(
|
||||
'-t', '--total',
|
||||
action='store_true',
|
||||
'--total',
|
||||
action=StoreTotal,
|
||||
help="Equivalent to --summary + --no-header + --small-total. "
|
||||
"Useful for scripting.")
|
||||
parser.add_argument(
|
||||
|
||||
+28
-17
@@ -489,26 +489,14 @@ def table(Result, results, diff_results=None, *,
|
||||
small_header=False,
|
||||
no_total=False,
|
||||
small_total=False,
|
||||
small_table=False,
|
||||
summary=False,
|
||||
total=False,
|
||||
**_):
|
||||
import builtins
|
||||
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
|
||||
if summary:
|
||||
small_header = True
|
||||
# total implies summary + no_header + small_total
|
||||
if total:
|
||||
summary = True
|
||||
no_header = True
|
||||
small_total = True
|
||||
|
||||
if by is None:
|
||||
by = Result._by
|
||||
@@ -1167,6 +1155,20 @@ if __name__ == "__main__":
|
||||
action='append',
|
||||
choices=CovResult._fields,
|
||||
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(
|
||||
'-D', '--define',
|
||||
dest='defines',
|
||||
@@ -1220,17 +1222,26 @@ if __name__ == "__main__":
|
||||
'--small-total',
|
||||
action='store_true',
|
||||
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(
|
||||
'-Q', '--small-table',
|
||||
action='store_true',
|
||||
help="Equivalent to --small-header + --no-total or --small-total.")
|
||||
'--small-table',
|
||||
action=StoreSmallTable,
|
||||
help="Equivalent to --small-header + --no-total.")
|
||||
parser.add_argument(
|
||||
'-Y', '--summary',
|
||||
action='store_true',
|
||||
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(
|
||||
'-t', '--total',
|
||||
action='store_true',
|
||||
'--total',
|
||||
action=StoreTotal,
|
||||
help="Equivalent to --summary + --no-header + --small-total. "
|
||||
"Useful for scripting.")
|
||||
parser.add_argument(
|
||||
|
||||
+32
-17
@@ -2264,26 +2264,14 @@ def table(Result, results, diff_results=None, *,
|
||||
small_header=False,
|
||||
no_total=False,
|
||||
small_total=False,
|
||||
small_table=False,
|
||||
summary=False,
|
||||
total=False,
|
||||
**_):
|
||||
import builtins
|
||||
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
|
||||
if summary:
|
||||
small_header = True
|
||||
# total implies summary + no_header + small_total
|
||||
if total:
|
||||
summary = True
|
||||
no_header = True
|
||||
small_total = True
|
||||
|
||||
if by is None:
|
||||
by = Result._by
|
||||
@@ -3326,6 +3314,24 @@ if __name__ == "__main__":
|
||||
)(*x.split('=', 1)),
|
||||
help="Like -f/--field, but hidden from the table renderer, "
|
||||
"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(
|
||||
'-D', '--define',
|
||||
dest='defines',
|
||||
@@ -3458,17 +3464,26 @@ if __name__ == "__main__":
|
||||
'--small-total',
|
||||
action='store_true',
|
||||
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(
|
||||
'-Q', '--small-table',
|
||||
action='store_true',
|
||||
help="Equivalent to --small-header + --no-total or --small-total.")
|
||||
'--small-table',
|
||||
action=StoreSmallTable,
|
||||
help="Equivalent to --small-header + --no-total.")
|
||||
parser.add_argument(
|
||||
'-Y', '--summary',
|
||||
action='store_true',
|
||||
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(
|
||||
'-t', '--total',
|
||||
action='store_true',
|
||||
'--total',
|
||||
action=StoreTotal,
|
||||
help="Equivalent to --summary + --no-header + --small-total. "
|
||||
"Useful for scripting.")
|
||||
parser.add_argument(
|
||||
|
||||
+28
-17
@@ -879,26 +879,14 @@ def table(Result, results, diff_results=None, *,
|
||||
small_header=False,
|
||||
no_total=False,
|
||||
small_total=False,
|
||||
small_table=False,
|
||||
summary=False,
|
||||
total=False,
|
||||
**_):
|
||||
import builtins
|
||||
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
|
||||
if summary:
|
||||
small_header = True
|
||||
# total implies summary + no_header + small_total
|
||||
if total:
|
||||
summary = True
|
||||
no_header = True
|
||||
small_total = True
|
||||
|
||||
if by is None:
|
||||
by = Result._by
|
||||
@@ -1483,6 +1471,20 @@ if __name__ == "__main__":
|
||||
action='append',
|
||||
choices=CtxResult._fields,
|
||||
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(
|
||||
'-D', '--define',
|
||||
dest='defines',
|
||||
@@ -1559,17 +1561,26 @@ if __name__ == "__main__":
|
||||
'--small-total',
|
||||
action='store_true',
|
||||
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(
|
||||
'-Q', '--small-table',
|
||||
action='store_true',
|
||||
help="Equivalent to --small-header + --no-total or --small-total.")
|
||||
'--small-table',
|
||||
action=StoreSmallTable,
|
||||
help="Equivalent to --small-header + --no-total.")
|
||||
parser.add_argument(
|
||||
'-Y', '--summary',
|
||||
action='store_true',
|
||||
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(
|
||||
'-t', '--total',
|
||||
action='store_true',
|
||||
'--total',
|
||||
action=StoreTotal,
|
||||
help="Equivalent to --summary + --no-header + --small-total. "
|
||||
"Useful for scripting.")
|
||||
parser.add_argument(
|
||||
|
||||
+28
-17
@@ -620,26 +620,14 @@ def table(Result, results, diff_results=None, *,
|
||||
small_header=False,
|
||||
no_total=False,
|
||||
small_total=False,
|
||||
small_table=False,
|
||||
summary=False,
|
||||
total=False,
|
||||
**_):
|
||||
import builtins
|
||||
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
|
||||
if summary:
|
||||
small_header = True
|
||||
# total implies summary + no_header + small_total
|
||||
if total:
|
||||
summary = True
|
||||
no_header = True
|
||||
small_total = True
|
||||
|
||||
if by is None:
|
||||
by = Result._by
|
||||
@@ -1188,6 +1176,20 @@ if __name__ == "__main__":
|
||||
action='append',
|
||||
choices=DataResult._fields,
|
||||
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(
|
||||
'-D', '--define',
|
||||
dest='defines',
|
||||
@@ -1241,17 +1243,26 @@ if __name__ == "__main__":
|
||||
'--small-total',
|
||||
action='store_true',
|
||||
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(
|
||||
'-Q', '--small-table',
|
||||
action='store_true',
|
||||
help="Equivalent to --small-header + --no-total or --small-total.")
|
||||
'--small-table',
|
||||
action=StoreSmallTable,
|
||||
help="Equivalent to --small-header + --no-total.")
|
||||
parser.add_argument(
|
||||
'-Y', '--summary',
|
||||
action='store_true',
|
||||
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(
|
||||
'-t', '--total',
|
||||
action='store_true',
|
||||
'--total',
|
||||
action=StoreTotal,
|
||||
help="Equivalent to --summary + --no-header + --small-total. "
|
||||
"Useful for scripting.")
|
||||
parser.add_argument(
|
||||
|
||||
+28
-17
@@ -978,26 +978,14 @@ def table(Result, results, diff_results=None, *,
|
||||
small_header=False,
|
||||
no_total=False,
|
||||
small_total=False,
|
||||
small_table=False,
|
||||
summary=False,
|
||||
total=False,
|
||||
**_):
|
||||
import builtins
|
||||
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
|
||||
if summary:
|
||||
small_header = True
|
||||
# total implies summary + no_header + small_total
|
||||
if total:
|
||||
summary = True
|
||||
no_header = True
|
||||
small_total = True
|
||||
|
||||
if by is None:
|
||||
by = Result._by
|
||||
@@ -1728,6 +1716,20 @@ if __name__ == "__main__":
|
||||
action='append',
|
||||
choices=PerfResult._fields,
|
||||
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(
|
||||
'-D', '--define',
|
||||
dest='defines',
|
||||
@@ -1809,17 +1811,26 @@ if __name__ == "__main__":
|
||||
'--small-total',
|
||||
action='store_true',
|
||||
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(
|
||||
'-Q', '--small-table',
|
||||
action='store_true',
|
||||
help="Equivalent to --small-header + --no-total or --small-total.")
|
||||
'--small-table',
|
||||
action=StoreSmallTable,
|
||||
help="Equivalent to --small-header + --no-total.")
|
||||
parser.add_argument(
|
||||
'-Y', '--summary',
|
||||
action='store_true',
|
||||
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(
|
||||
'-t', '--total',
|
||||
action='store_true',
|
||||
'--total',
|
||||
action=StoreTotal,
|
||||
help="Equivalent to --summary + --no-header + --small-total. "
|
||||
"Useful for scripting.")
|
||||
parser.add_argument(
|
||||
|
||||
+28
-17
@@ -952,26 +952,14 @@ def table(Result, results, diff_results=None, *,
|
||||
small_header=False,
|
||||
no_total=False,
|
||||
small_total=False,
|
||||
small_table=False,
|
||||
summary=False,
|
||||
total=False,
|
||||
**_):
|
||||
import builtins
|
||||
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
|
||||
if summary:
|
||||
small_header = True
|
||||
# total implies summary + no_header + small_total
|
||||
if total:
|
||||
summary = True
|
||||
no_header = True
|
||||
small_total = True
|
||||
|
||||
if by is None:
|
||||
by = Result._by
|
||||
@@ -1728,6 +1716,20 @@ if __name__ == "__main__":
|
||||
action='append',
|
||||
choices=PerfBdResult._fields,
|
||||
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(
|
||||
'-D', '--define',
|
||||
dest='defines',
|
||||
@@ -1809,17 +1811,26 @@ if __name__ == "__main__":
|
||||
'--small-total',
|
||||
action='store_true',
|
||||
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(
|
||||
'-Q', '--small-table',
|
||||
action='store_true',
|
||||
help="Equivalent to --small-header + --no-total or --small-total.")
|
||||
'--small-table',
|
||||
action=StoreSmallTable,
|
||||
help="Equivalent to --small-header + --no-total.")
|
||||
parser.add_argument(
|
||||
'-Y', '--summary',
|
||||
action='store_true',
|
||||
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(
|
||||
'-t', '--total',
|
||||
action='store_true',
|
||||
'--total',
|
||||
action=StoreTotal,
|
||||
help="Equivalent to --summary + --no-header + --small-total. "
|
||||
"Useful for scripting.")
|
||||
parser.add_argument(
|
||||
|
||||
+28
-17
@@ -620,26 +620,14 @@ def table(Result, results, diff_results=None, *,
|
||||
small_header=False,
|
||||
no_total=False,
|
||||
small_total=False,
|
||||
small_table=False,
|
||||
summary=False,
|
||||
total=False,
|
||||
**_):
|
||||
import builtins
|
||||
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
|
||||
if summary:
|
||||
small_header = True
|
||||
# total implies summary + no_header + small_total
|
||||
if total:
|
||||
summary = True
|
||||
no_header = True
|
||||
small_total = True
|
||||
|
||||
if by is None:
|
||||
by = Result._by
|
||||
@@ -1226,6 +1214,20 @@ if __name__ == "__main__":
|
||||
action='append',
|
||||
choices=StackResult._fields,
|
||||
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(
|
||||
'-D', '--define',
|
||||
dest='defines',
|
||||
@@ -1302,17 +1304,26 @@ if __name__ == "__main__":
|
||||
'--small-total',
|
||||
action='store_true',
|
||||
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(
|
||||
'-Q', '--small-table',
|
||||
action='store_true',
|
||||
help="Equivalent to --small-header + --no-total or --small-total.")
|
||||
'--small-table',
|
||||
action=StoreSmallTable,
|
||||
help="Equivalent to --small-header + --no-total.")
|
||||
parser.add_argument(
|
||||
'-Y', '--summary',
|
||||
action='store_true',
|
||||
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(
|
||||
'-t', '--total',
|
||||
action='store_true',
|
||||
'--total',
|
||||
action=StoreTotal,
|
||||
help="Equivalent to --summary + --no-header + --small-total. "
|
||||
"Useful for scripting.")
|
||||
parser.add_argument(
|
||||
|
||||
+28
-17
@@ -768,26 +768,14 @@ def table(Result, results, diff_results=None, *,
|
||||
small_header=False,
|
||||
no_total=False,
|
||||
small_total=False,
|
||||
small_table=False,
|
||||
summary=False,
|
||||
total=False,
|
||||
**_):
|
||||
import builtins
|
||||
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
|
||||
if summary:
|
||||
small_header = True
|
||||
# total implies summary + no_header + small_total
|
||||
if total:
|
||||
summary = True
|
||||
no_header = True
|
||||
small_total = True
|
||||
|
||||
if by is None:
|
||||
by = Result._by
|
||||
@@ -1372,6 +1360,20 @@ if __name__ == "__main__":
|
||||
action='append',
|
||||
choices=StructResult._fields,
|
||||
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(
|
||||
'-D', '--define',
|
||||
dest='defines',
|
||||
@@ -1448,17 +1450,26 @@ if __name__ == "__main__":
|
||||
'--small-total',
|
||||
action='store_true',
|
||||
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(
|
||||
'-Q', '--small-table',
|
||||
action='store_true',
|
||||
help="Equivalent to --small-header + --no-total or --small-total.")
|
||||
'--small-table',
|
||||
action=StoreSmallTable,
|
||||
help="Equivalent to --small-header + --no-total.")
|
||||
parser.add_argument(
|
||||
'-Y', '--summary',
|
||||
action='store_true',
|
||||
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(
|
||||
'-t', '--total',
|
||||
action='store_true',
|
||||
'--total',
|
||||
action=StoreTotal,
|
||||
help="Equivalent to --summary + --no-header + --small-total. "
|
||||
"Useful for scripting.")
|
||||
parser.add_argument(
|
||||
|
||||
Reference in New Issue
Block a user