@@ -133,6 +133,7 @@ def _extract_headers_cli() -> None:
133133def _extract_next_data_cli () -> None :
134134 import sys
135135 from pathlib import Path
136+ _NOTSET = object ()
136137
137138 if len (sys .argv ) == 1 :
138139 print ("Enter html text below." )
@@ -147,7 +148,7 @@ def _extract_next_data_cli() -> None:
147148 parser .add_argument ("--include-prefixed" , "-p" , action = "store_true" )
148149 parser .add_argument ("--include" , "-i" , action = "append" , type = str , default = [], help = "Include only specific prefixes." )
149150 parser .add_argument ("--exclude" , "-x" , action = "append" , type = str , default = [], help = "Exclude specific prefixes." )
150- parser .add_argument ("--outline" , action = "store_true" , help = "Show a outline for the data." )
151+ parser .add_argument ("--outline" , nargs = "?" , type = int , default = _NOTSET , help = "Show a outline for the data." )
151152 args = parser .parse_args ()
152153 # return print(args)
153154
@@ -172,7 +173,7 @@ def _extract_next_data_cli() -> None:
172173 console .print (item .value )
173174 return
174175
175- if args .outline :
176+ if args .outline is not _NOTSET :
176177 from rich .table import Table
177178
178179 table = Table (title = "Next Data Outline" )
@@ -190,9 +191,10 @@ def _extract_next_data_cli() -> None:
190191 if not args .include_prefixed and item .prefix :
191192 continue
192193 data_raw = json .dumps (item .value , ensure_ascii = False )
193- truncated = data_raw [:80 ]
194- if len (data_raw ) < 80 :
195- truncated = truncated + " " + "." * (80 - len (truncated ))
194+ truncated_limit = args .outline or 80
195+ truncated = data_raw [:truncated_limit ]
196+ if len (data_raw ) < truncated_limit :
197+ truncated = truncated + " " + "." * (truncated_limit - len (truncated ))
196198 if not args .include_prefixed :
197199 table .add_row (item .hexdigit , str (len (data_raw )), truncated )
198200 else :
0 commit comments