File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed
Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ ptx-help-gap-size = gap size in columns between output fields
2121ptx-help-ignore-file = read ignore word list from FILE
2222ptx-help-only-file = read only word list from this FILE
2323ptx-help-references = first field of each line is a reference
24+ ptx-help-typeset-mode = change the default width from 72 to 100
2425ptx-help-width = output width in columns, reference excluded
2526
2627# Error messages
Original file line number Diff line number Diff line change @@ -247,6 +247,8 @@ fn get_config(matches: &mut clap::ArgMatches) -> UResult<Config> {
247247 . expect ( err_msg)
248248 . parse ( )
249249 . map_err ( PtxError :: ParseError ) ?;
250+ } else if matches. get_flag ( options:: TYPESET_MODE ) {
251+ config. line_width = 100 ;
250252 }
251253 if matches. contains_id ( options:: GAP_SIZE ) {
252254 config. gap_size = matches
@@ -894,6 +896,7 @@ mod options {
894896 pub static IGNORE_FILE : & str = "ignore-file" ;
895897 pub static ONLY_FILE : & str = "only-file" ;
896898 pub static REFERENCES : & str = "references" ;
899+ pub static TYPESET_MODE : & str = "typeset-mode" ;
897900 pub static WIDTH : & str = "width" ;
898901}
899902
@@ -1070,6 +1073,13 @@ pub fn uu_app() -> Command {
10701073 . value_name ( "FILE" )
10711074 . action ( ArgAction :: SetTrue ) ,
10721075 )
1076+ . arg (
1077+ Arg :: new ( options:: TYPESET_MODE )
1078+ . short ( 't' )
1079+ . long ( options:: TYPESET_MODE )
1080+ . help ( translate ! ( "ptx-help-typeset-mode" ) )
1081+ . action ( ArgAction :: SetTrue ) ,
1082+ )
10731083 . arg (
10741084 Arg :: new ( options:: WIDTH )
10751085 . short ( 'w' )
Original file line number Diff line number Diff line change @@ -356,6 +356,32 @@ fn test_narrow_width_with_long_reference_no_panic() {
356356 . stdout_only ( ":1 content\n " ) ;
357357}
358358
359+ #[ test]
360+ fn test_typeset_mode_default_width_100 ( ) {
361+ new_ucmd ! ( )
362+ . args ( & [ "-t" ] )
363+ . pipe_in ( "bar\n " )
364+ . succeeds ( )
365+ . stdout_only ( format ! ( "{}bar\n " , " " . repeat( 53 ) ) ) ;
366+ }
367+
368+ #[ test]
369+ fn test_typeset_mode_w_overrides_t ( ) {
370+ new_ucmd ! ( )
371+ . args ( & [ "-t" , "-w" , "10" ] )
372+ . pipe_in ( "bar\n " )
373+ . succeeds ( )
374+ . stdout_only ( format ! ( "{}bar\n " , " " . repeat( 8 ) ) ) ;
375+ }
376+
377+ #[ test]
378+ fn test_default_width_72 ( ) {
379+ new_ucmd ! ( )
380+ . pipe_in ( "bar\n " )
381+ . succeeds ( )
382+ . stdout_only ( format ! ( "{}bar\n " , " " . repeat( 39 ) ) ) ;
383+ }
384+
359385#[ test]
360386fn test_invalid_regex_word_trailing_backslash ( ) {
361387 new_ucmd ! ( ) . args ( & [ "-W" , "bar\\ " ] ) . succeeds ( ) . no_stderr ( ) ;
You can’t perform that action at this time.
0 commit comments