mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
cp: let clap render help & version
This commit is contained in:
parent
19e04a26cf
commit
7ffc16c31d
1 changed files with 25 additions and 38 deletions
|
@ -23,7 +23,7 @@ use thiserror::Error;
|
||||||
|
|
||||||
use platform::copy_on_write;
|
use platform::copy_on_write;
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uucore::error::{UClapError, UError, UResult, UUsageError, set_exit_code};
|
use uucore::error::{UError, UResult, UUsageError, set_exit_code};
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use uucore::fs::make_fifo;
|
use uucore::fs::make_fifo;
|
||||||
use uucore::fs::{
|
use uucore::fs::{
|
||||||
|
@ -796,20 +796,8 @@ pub fn uu_app() -> Command {
|
||||||
|
|
||||||
#[uucore::main]
|
#[uucore::main]
|
||||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let matches = uu_app().try_get_matches_from(args);
|
let mut matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
// The error is parsed here because we do not want version or help being printed to stderr.
|
|
||||||
if let Err(e) = matches {
|
|
||||||
let mut app = uu_app();
|
|
||||||
|
|
||||||
match e.kind() {
|
|
||||||
clap::error::ErrorKind::DisplayHelp => {
|
|
||||||
app.print_help()?;
|
|
||||||
}
|
|
||||||
clap::error::ErrorKind::DisplayVersion => print!("{}", app.render_version()),
|
|
||||||
_ => return Err(Box::new(e.with_exit_code(1))),
|
|
||||||
};
|
|
||||||
} else if let Ok(mut matches) = matches {
|
|
||||||
let options = Options::from_matches(&matches)?;
|
let options = Options::from_matches(&matches)?;
|
||||||
|
|
||||||
if options.overwrite == OverwriteMode::NoClobber && options.backup != BackupMode::None {
|
if options.overwrite == OverwriteMode::NoClobber && options.backup != BackupMode::None {
|
||||||
|
@ -836,7 +824,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
};
|
};
|
||||||
set_exit_code(EXIT_ERR);
|
set_exit_code(EXIT_ERR);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue