Skip to content

Commit 046fe55

Browse files
committed
Update cli
1 parent 63c6f50 commit 046fe55

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

Lib/profiling/sampling/cli.py

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def _add_mode_options(parser):
369369
)
370370

371371

372-
def _add_format_options(parser, include_compression=True):
372+
def _add_format_options(parser, include_compression=True, include_binary=True):
373373
"""Add output format options to a parser."""
374374
output_group = parser.add_argument_group("Output options")
375375
format_group = output_group.add_mutually_exclusive_group()
@@ -408,13 +408,14 @@ def _add_format_options(parser, include_compression=True):
408408
dest="format",
409409
help="Generate interactive HTML heatmap visualization with line-level sample counts",
410410
)
411-
format_group.add_argument(
412-
"--binary",
413-
action="store_const",
414-
const="binary",
415-
dest="format",
416-
help="Generate high-performance binary format (use 'replay' command to convert)",
417-
)
411+
if include_binary:
412+
format_group.add_argument(
413+
"--binary",
414+
action="store_const",
415+
const="binary",
416+
dest="format",
417+
help="Generate high-performance binary format (use 'replay' command to convert)",
418+
)
418419
parser.set_defaults(format="pstats")
419420

420421
if include_compression:
@@ -579,11 +580,8 @@ def _validate_args(args, parser):
579580
args: Parsed command-line arguments
580581
parser: ArgumentParser instance for error reporting
581582
"""
582-
# Replay command has minimal validation
583+
# Replay command has no special validation needed
583584
if getattr(args, 'command', None) == "replay":
584-
# Can't replay to binary format
585-
if args.format == "binary":
586-
parser.error("Cannot replay to binary format. Use a different output format.")
587585
return
588586

589587
# Check if live mode is available
@@ -784,7 +782,7 @@ def main():
784782
"input_file",
785783
help="Binary profile file to replay",
786784
)
787-
_add_format_options(replay_parser, include_compression=False)
785+
_add_format_options(replay_parser, include_compression=False, include_binary=False)
788786
_add_pstats_options(replay_parser)
789787

790788
# Parse arguments
@@ -1041,10 +1039,6 @@ def _handle_replay(args):
10411039
if not os.path.exists(args.input_file):
10421040
sys.exit(f"Error: Input file not found: {args.input_file}")
10431041

1044-
# Can't replay to binary format
1045-
if args.format == "binary":
1046-
sys.exit("Error: Cannot replay to binary format. Use a different output format.")
1047-
10481042
with BinaryReader(args.input_file) as reader:
10491043
info = reader.get_info()
10501044
interval = info['sample_interval_us']

0 commit comments

Comments
 (0)