mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-02 05:57:46 +00:00
printf: remove unused argument name from help
printf --help is currently listing three usage forms: ``` Usage: coreutils printf FORMATSTRING [ARGUMENT]... coreutils printf FORMAT [ARGUMENT]... coreutils printf OPTION ``` But there are only two usage forms, since there is no difference between "FORMAT" and "FORMATSTRING". Remove references to "FORMATSTRING", and use "FORMAT" in all places where "FORMATSTRING" appeared, since other implementations of `printf` use the argument name "FORMAT".
This commit is contained in:
parent
3f694faa2e
commit
d70990e0cc
2 changed files with 10 additions and 13 deletions
|
@ -1,9 +1,8 @@
|
|||
<!-- spell-checker:ignore formatstring templating parameterizing each's -->
|
||||
<!-- spell-checker:ignore templating parameterizing each's -->
|
||||
|
||||
# printf
|
||||
|
||||
```
|
||||
printf FORMATSTRING [ARGUMENT]...
|
||||
printf FORMAT [ARGUMENT]...
|
||||
printf OPTION
|
||||
```
|
||||
|
|
|
@ -2,14 +2,12 @@
|
|||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
#![allow(dead_code)]
|
||||
// spell-checker:ignore (change!) each's
|
||||
// spell-checker:ignore (ToDO) LONGHELP FORMATSTRING templating parameterizing formatstr
|
||||
|
||||
use std::io::stdout;
|
||||
use std::ops::ControlFlow;
|
||||
#![allow(dead_code)]
|
||||
|
||||
use clap::{crate_version, Arg, ArgAction, Command};
|
||||
use std::io::stdout;
|
||||
use std::ops::ControlFlow;
|
||||
use uucore::error::{UResult, UUsageError};
|
||||
use uucore::format::{parse_spec_and_escape, FormatArgument, FormatItem};
|
||||
use uucore::{format_usage, help_about, help_section, help_usage};
|
||||
|
@ -21,7 +19,7 @@ const ABOUT: &str = help_about!("printf.md");
|
|||
const AFTER_HELP: &str = help_section!("after help", "printf.md");
|
||||
|
||||
mod options {
|
||||
pub const FORMATSTRING: &str = "FORMATSTRING";
|
||||
pub const FORMAT: &str = "FORMAT";
|
||||
pub const ARGUMENT: &str = "ARGUMENT";
|
||||
}
|
||||
|
||||
|
@ -29,8 +27,8 @@ mod options {
|
|||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let matches = uu_app().get_matches_from(args);
|
||||
|
||||
let format_string = matches
|
||||
.get_one::<String>(options::FORMATSTRING)
|
||||
let format = matches
|
||||
.get_one::<String>(options::FORMAT)
|
||||
.ok_or_else(|| UUsageError::new(1, "missing operand"))?;
|
||||
|
||||
let values: Vec<_> = match matches.get_many::<String>(options::ARGUMENT) {
|
||||
|
@ -40,7 +38,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
|
||||
let mut format_seen = false;
|
||||
let mut args = values.iter().peekable();
|
||||
for item in parse_spec_and_escape(format_string.as_ref()) {
|
||||
for item in parse_spec_and_escape(format.as_ref()) {
|
||||
if let Ok(FormatItem::Spec(_)) = item {
|
||||
format_seen = true;
|
||||
}
|
||||
|
@ -57,7 +55,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
}
|
||||
|
||||
while args.peek().is_some() {
|
||||
for item in parse_spec_and_escape(format_string.as_ref()) {
|
||||
for item in parse_spec_and_escape(format.as_ref()) {
|
||||
match item?.write(stdout(), &mut args)? {
|
||||
ControlFlow::Continue(()) => {}
|
||||
ControlFlow::Break(()) => return Ok(()),
|
||||
|
@ -88,6 +86,6 @@ pub fn uu_app() -> Command {
|
|||
.help("Print version information")
|
||||
.action(ArgAction::Version),
|
||||
)
|
||||
.arg(Arg::new(options::FORMATSTRING))
|
||||
.arg(Arg::new(options::FORMAT))
|
||||
.arg(Arg::new(options::ARGUMENT).action(ArgAction::Append))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue