Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

printf: remove unused argument name from help #6807

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/uu/printf/printf.md
Original file line number Diff line number Diff line change
@@ -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
```
Expand Down
18 changes: 8 additions & 10 deletions src/uu/printf/src/printf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 clap::{crate_version, Arg, ArgAction, Command};
use std::io::stdout;
use std::ops::ControlFlow;

use clap::{crate_version, Arg, ArgAction, Command};
use uucore::error::{UResult, UUsageError};
use uucore::format::{parse_spec_and_escape, FormatArgument, FormatItem};
use uucore::{format_usage, help_about, help_section, help_usage};
Expand All @@ -21,16 +19,16 @@ 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";
}

#[uucore::main]
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) {
Expand All @@ -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;
}
Expand All @@ -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(()),
Expand Down Expand Up @@ -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