1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

nl: make --no-renumber a flag

This commit is contained in:
Daniel Hofstetter 2023-07-04 10:37:10 +02:00
parent 6e3ab23183
commit fee5225cb6
3 changed files with 10 additions and 2 deletions

View file

@ -29,7 +29,7 @@ fn parse_style(chars: &[char]) -> Result<crate::NumberingStyle, String> {
pub fn parse_options(settings: &mut crate::Settings, opts: &clap::ArgMatches) -> Vec<String> {
// This vector holds error messages encountered.
let mut errs: Vec<String> = vec![];
settings.renumber = !opts.contains_id(options::NO_RENUMBER);
settings.renumber = opts.get_flag(options::NO_RENUMBER);
match opts.get_one::<String>(options::NUMBER_SEPARATOR) {
None => {}
Some(val) => {

View file

@ -213,7 +213,8 @@ pub fn uu_app() -> Command {
Arg::new(options::NO_RENUMBER)
.short('p')
.long(options::NO_RENUMBER)
.help("do not reset line numbers at logical pages"),
.help("do not reset line numbers at logical pages")
.action(ArgAction::SetFalse),
)
.arg(
Arg::new(options::NUMBER_SEPARATOR)

View file

@ -71,3 +71,10 @@ fn test_sections_and_styles() {
}
// spell-checker:enable
}
#[test]
fn test_no_renumber() {
for arg in ["-p", "--no-renumber"] {
new_ucmd!().arg(arg).succeeds();
}
}