22//
33// For the full copyright and license information, please view the LICENSE
44// file that was distributed with this source code.
5+
56#![ allow( dead_code) ]
6- // spell-checker:ignore (change!) each's
7- // spell-checker:ignore (ToDO) LONGHELP FORMATSTRING templating parameterizing formatstr
87
8+ use clap:: { crate_version, Arg , ArgAction , Command } ;
99use std:: io:: stdout;
1010use std:: ops:: ControlFlow ;
11-
12- use clap:: { crate_version, Arg , ArgAction , Command } ;
1311use uucore:: error:: { UResult , UUsageError } ;
1412use uucore:: format:: { parse_spec_and_escape, FormatArgument , FormatItem } ;
1513use uucore:: { format_usage, help_about, help_section, help_usage} ;
@@ -21,16 +19,16 @@ const ABOUT: &str = help_about!("printf.md");
2119const AFTER_HELP : & str = help_section ! ( "after help" , "printf.md" ) ;
2220
2321mod options {
24- pub const FORMATSTRING : & str = "FORMATSTRING " ;
22+ pub const FORMAT : & str = "FORMAT " ;
2523 pub const ARGUMENT : & str = "ARGUMENT" ;
2624}
2725
2826#[ uucore:: main]
2927pub fn uumain ( args : impl uucore:: Args ) -> UResult < ( ) > {
3028 let matches = uu_app ( ) . get_matches_from ( args) ;
3129
32- let format_string = matches
33- . get_one :: < String > ( options:: FORMATSTRING )
30+ let format = matches
31+ . get_one :: < String > ( options:: FORMAT )
3432 . ok_or_else ( || UUsageError :: new ( 1 , "missing operand" ) ) ?;
3533
3634 let values: Vec < _ > = match matches. get_many :: < String > ( options:: ARGUMENT ) {
@@ -40,7 +38,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
4038
4139 let mut format_seen = false ;
4240 let mut args = values. iter ( ) . peekable ( ) ;
43- for item in parse_spec_and_escape ( format_string . as_ref ( ) ) {
41+ for item in parse_spec_and_escape ( format . as_ref ( ) ) {
4442 if let Ok ( FormatItem :: Spec ( _) ) = item {
4543 format_seen = true ;
4644 }
@@ -57,7 +55,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
5755 }
5856
5957 while args. peek ( ) . is_some ( ) {
60- for item in parse_spec_and_escape ( format_string . as_ref ( ) ) {
58+ for item in parse_spec_and_escape ( format . as_ref ( ) ) {
6159 match item?. write ( stdout ( ) , & mut args) ? {
6260 ControlFlow :: Continue ( ( ) ) => { }
6361 ControlFlow :: Break ( ( ) ) => return Ok ( ( ) ) ,
@@ -88,6 +86,6 @@ pub fn uu_app() -> Command {
8886 . help ( "Print version information" )
8987 . action ( ArgAction :: Version ) ,
9088 )
91- . arg ( Arg :: new ( options:: FORMATSTRING ) )
89+ . arg ( Arg :: new ( options:: FORMAT ) )
9290 . arg ( Arg :: new ( options:: ARGUMENT ) . action ( ArgAction :: Append ) )
9391}
0 commit comments