@@ -27,6 +27,7 @@ mod options {
2727 pub const MAX_ARGS : & str = "max-args" ;
2828 pub const MAX_CHARS : & str = "max-chars" ;
2929 pub const MAX_LINES : & str = "max-lines" ;
30+ pub const MAX_LINES_L : & str = "max-lines-l" ;
3031 pub const MAX_PROCS : & str = "max-procs" ;
3132 pub const NO_RUN_IF_EMPTY : & str = "no-run-if-empty" ;
3233 pub const NULL : & str = "null" ;
@@ -927,6 +928,17 @@ fn do_xargs(args: &[&str]) -> Result<CommandResult, XargsError> {
927928 )
928929 . value_parser ( validate_positive_usize) ,
929930 )
931+ . arg (
932+ Arg :: new ( options:: MAX_LINES_L )
933+ . short ( 'l' )
934+ . num_args ( 0 ..=1 )
935+ . help (
936+ "Equivalent to -L, but with a default value of 1 if max-lines \
937+ is unspecified",
938+ )
939+ . value_name ( "max-lines" )
940+ . value_parser ( validate_positive_usize) ,
941+ )
930942 . arg (
931943 Arg :: new ( options:: MAX_PROCS )
932944 . short ( 'P' )
@@ -1032,7 +1044,15 @@ fn do_xargs(args: &[&str]) -> Result<CommandResult, XargsError> {
10321044 exit_if_pass_char_limit : matches. get_flag ( options:: EXIT ) ,
10331045 max_args : matches. get_one :: < usize > ( options:: MAX_ARGS ) . copied ( ) ,
10341046 max_chars : matches. get_one :: < usize > ( options:: MAX_CHARS ) . copied ( ) ,
1035- max_lines : matches. get_one :: < usize > ( options:: MAX_LINES ) . copied ( ) ,
1047+ max_lines : [ options:: MAX_LINES , options:: MAX_LINES_L ]
1048+ . iter ( )
1049+ . find_map ( |& option| {
1050+ matches. contains_id ( option) . then ( || {
1051+ matches
1052+ . get_one :: < usize > ( option)
1053+ . map_or_else ( || 1 , std:: borrow:: ToOwned :: to_owned)
1054+ } )
1055+ } ) ,
10361056 no_run_if_empty : matches. get_flag ( options:: NO_RUN_IF_EMPTY ) ,
10371057 null : matches. get_flag ( options:: NULL ) ,
10381058 replace : [ options:: REPLACE_I , options:: REPLACE ]
0 commit comments