1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

false,true: Align behavior of short flags to GNU

This commit is contained in:
Andreas Molzer 2022-02-01 12:32:30 +01:00
parent 149399c1bf
commit c1e108933f
2 changed files with 26 additions and 4 deletions

View file

@ -4,7 +4,7 @@
// *
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
use clap::{App, AppSettings, ErrorKind};
use clap::{App, Arg, ArgSettings, ErrorKind};
use std::io::Write;
use uucore::error::{set_exit_code, UResult};
@ -42,5 +42,16 @@ pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(clap::crate_version!())
.about(ABOUT)
.setting(AppSettings::InferLongArgs)
// Hide the default -V and -h for version and help.
// This requires us to overwrite short, not short_aliases.
.arg(
Arg::new("dummy-help")
.short('h')
.setting(ArgSettings::Hidden),
)
.arg(
Arg::new("dummy-version")
.short('V')
.setting(ArgSettings::Hidden),
)
}

View file

@ -4,7 +4,7 @@
// *
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
use clap::{App, AppSettings, ErrorKind};
use clap::{App, Arg, ArgSettings, ErrorKind};
use std::io::Write;
use uucore::error::{set_exit_code, UResult};
@ -40,5 +40,16 @@ pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(clap::crate_version!())
.about(ABOUT)
.setting(AppSettings::InferLongArgs)
// Hide the default -V and -h for version and help.
// This requires us to overwrite short, not short_aliases.
.arg(
Arg::new("dummy-help")
.short('h')
.setting(ArgSettings::Hidden),
)
.arg(
Arg::new("dummy-version")
.short('V')
.setting(ArgSettings::Hidden),
)
}