File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change 11"""The pyhf utils CLI subcommand."""
22import logging
3+ from pathlib import Path
34
45import click
56from pyhf import utils
@@ -13,5 +14,21 @@ def cli():
1314
1415
1516@cli .command ()
16- def debug ():
17- click .echo (utils .debug_info ())
17+ @click .option (
18+ "-o" ,
19+ "--output-file" ,
20+ help = "The location of the output file. If not specified, prints to screen." ,
21+ default = None ,
22+ )
23+ def debug (output_file ):
24+ debug_info = utils .debug_info ()
25+
26+ if output_file :
27+ output_file = Path (output_file )
28+ output_file .parent .mkdir (parents = True , exist_ok = True )
29+
30+ with open (output_file , "w+" , encoding = "utf-8" ) as out_file :
31+ out_file .write (debug_info )
32+ log .debug (f"Written to { output_file } " )
33+ else :
34+ click .echo (debug_info )
You can’t perform that action at this time.
0 commit comments