55
66// spell-checker:ignore (vars) seekable memrchr
77
8- use clap:: { Arg , ArgAction , ArgMatches , Command } ;
8+ use clap:: ArgMatches ;
99use memchr:: memrchr_iter;
1010use std:: ffi:: OsString ;
1111use std:: fs:: File ;
@@ -18,20 +18,14 @@ use thiserror::Error;
1818use uucore:: display:: { Quotable , print_verbatim} ;
1919use uucore:: error:: { FromIo , UError , UResult , USimpleError } ;
2020use uucore:: line_ending:: LineEnding ;
21+ use uucore:: show;
2122use uucore:: translate;
22- use uucore:: { format_usage, show} ;
2323
2424const BUF_SIZE : usize = 65536 ;
2525
26- mod options {
27- pub const BYTES : & str = "BYTES" ;
28- pub const LINES : & str = "LINES" ;
29- pub const QUIET : & str = "QUIET" ;
30- pub const VERBOSE : & str = "VERBOSE" ;
31- pub const ZERO : & str = "ZERO" ;
32- pub const FILES : & str = "FILE" ;
33- pub const PRESUME_INPUT_PIPE : & str = "-PRESUME-INPUT-PIPE" ;
34- }
26+ mod cli;
27+ use crate :: cli:: options;
28+ pub use crate :: cli:: uu_app;
3529
3630mod parse;
3731mod take;
@@ -66,71 +60,6 @@ impl UError for HeadError {
6660
6761type HeadResult < T > = Result < T , HeadError > ;
6862
69- pub fn uu_app ( ) -> Command {
70- Command :: new ( "head" )
71- . version ( uucore:: crate_version!( ) )
72- . help_template ( uucore:: localized_help_template ( "head" ) )
73- . about ( translate ! ( "head-about" ) )
74- . override_usage ( format_usage ( & translate ! ( "head-usage" ) ) )
75- . infer_long_args ( true )
76- . arg (
77- Arg :: new ( options:: BYTES )
78- . short ( 'c' )
79- . long ( "bytes" )
80- . value_name ( "[-]NUM" )
81- . help ( translate ! ( "head-help-bytes" ) )
82- . overrides_with_all ( [ options:: BYTES , options:: LINES ] )
83- . allow_hyphen_values ( true ) ,
84- )
85- . arg (
86- Arg :: new ( options:: LINES )
87- . short ( 'n' )
88- . long ( "lines" )
89- . value_name ( "[-]NUM" )
90- . help ( translate ! ( "head-help-lines" ) )
91- . overrides_with_all ( [ options:: LINES , options:: BYTES ] )
92- . allow_hyphen_values ( true ) ,
93- )
94- . arg (
95- Arg :: new ( options:: QUIET )
96- . short ( 'q' )
97- . long ( "quiet" )
98- . visible_alias ( "silent" )
99- . help ( translate ! ( "head-help-quiet" ) )
100- . overrides_with_all ( [ options:: VERBOSE , options:: QUIET ] )
101- . action ( ArgAction :: SetTrue ) ,
102- )
103- . arg (
104- Arg :: new ( options:: VERBOSE )
105- . short ( 'v' )
106- . long ( "verbose" )
107- . help ( translate ! ( "head-help-verbose" ) )
108- . overrides_with_all ( [ options:: QUIET , options:: VERBOSE ] )
109- . action ( ArgAction :: SetTrue ) ,
110- )
111- . arg (
112- Arg :: new ( options:: PRESUME_INPUT_PIPE )
113- . long ( "presume-input-pipe" )
114- . alias ( "-presume-input-pipe" )
115- . hide ( true )
116- . action ( ArgAction :: SetTrue ) ,
117- )
118- . arg (
119- Arg :: new ( options:: ZERO )
120- . short ( 'z' )
121- . long ( "zero-terminated" )
122- . help ( translate ! ( "head-help-zero-terminated" ) )
123- . overrides_with ( options:: ZERO )
124- . action ( ArgAction :: SetTrue ) ,
125- )
126- . arg (
127- Arg :: new ( options:: FILES )
128- . action ( ArgAction :: Append )
129- . value_parser ( clap:: value_parser!( OsString ) )
130- . value_hint ( clap:: ValueHint :: FilePath ) ,
131- )
132- }
133-
13463#[ derive( Debug , PartialEq ) ]
13564enum Mode {
13665 FirstLines ( u64 ) ,
0 commit comments