mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 12:37:49 +00:00
ln: Adapt to modified backup_control
interface
This commit is contained in:
parent
ce0d9bce28
commit
2a1a923acc
1 changed files with 5 additions and 41 deletions
|
@ -54,7 +54,6 @@ enum LnError {
|
||||||
FailedToLink(String),
|
FailedToLink(String),
|
||||||
MissingDestination(String),
|
MissingDestination(String),
|
||||||
ExtraOperand(String),
|
ExtraOperand(String),
|
||||||
InvalidBackupMode(String),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for LnError {
|
impl Display for LnError {
|
||||||
|
@ -72,7 +71,6 @@ impl Display for LnError {
|
||||||
s,
|
s,
|
||||||
uucore::execution_phrase()
|
uucore::execution_phrase()
|
||||||
),
|
),
|
||||||
Self::InvalidBackupMode(s) => write!(f, "{}", s),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +85,6 @@ impl UError for LnError {
|
||||||
Self::FailedToLink(_) => 1,
|
Self::FailedToLink(_) => 1,
|
||||||
Self::MissingDestination(_) => 1,
|
Self::MissingDestination(_) => 1,
|
||||||
Self::ExtraOperand(_) => 1,
|
Self::ExtraOperand(_) => 1,
|
||||||
Self::InvalidBackupMode(_) => 1,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,13 +116,10 @@ fn long_usage() -> String {
|
||||||
static ABOUT: &str = "change file owner and group";
|
static ABOUT: &str = "change file owner and group";
|
||||||
|
|
||||||
mod options {
|
mod options {
|
||||||
pub const BACKUP_NO_ARG: &str = "b";
|
|
||||||
pub const BACKUP: &str = "backup";
|
|
||||||
pub const FORCE: &str = "force";
|
pub const FORCE: &str = "force";
|
||||||
pub const INTERACTIVE: &str = "interactive";
|
pub const INTERACTIVE: &str = "interactive";
|
||||||
pub const NO_DEREFERENCE: &str = "no-dereference";
|
pub const NO_DEREFERENCE: &str = "no-dereference";
|
||||||
pub const SYMBOLIC: &str = "symbolic";
|
pub const SYMBOLIC: &str = "symbolic";
|
||||||
pub const SUFFIX: &str = "suffix";
|
|
||||||
pub const TARGET_DIRECTORY: &str = "target-directory";
|
pub const TARGET_DIRECTORY: &str = "target-directory";
|
||||||
pub const NO_TARGET_DIRECTORY: &str = "no-target-directory";
|
pub const NO_TARGET_DIRECTORY: &str = "no-target-directory";
|
||||||
pub const RELATIVE: &str = "relative";
|
pub const RELATIVE: &str = "relative";
|
||||||
|
@ -164,19 +158,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
OverwriteMode::NoClobber
|
OverwriteMode::NoClobber
|
||||||
};
|
};
|
||||||
|
|
||||||
let backup_mode = backup_control::determine_backup_mode(
|
let backup_mode = backup_control::determine_backup_mode(&matches)?;
|
||||||
matches.is_present(options::BACKUP_NO_ARG),
|
let backup_suffix = backup_control::determine_backup_suffix(&matches);
|
||||||
matches.is_present(options::BACKUP),
|
|
||||||
matches.value_of(options::BACKUP),
|
|
||||||
);
|
|
||||||
let backup_mode = match backup_mode {
|
|
||||||
Err(err) => {
|
|
||||||
return Err(LnError::InvalidBackupMode(err).into());
|
|
||||||
}
|
|
||||||
Ok(mode) => mode,
|
|
||||||
};
|
|
||||||
|
|
||||||
let backup_suffix = backup_control::determine_backup_suffix(matches.value_of(options::SUFFIX));
|
|
||||||
|
|
||||||
let settings = Settings {
|
let settings = Settings {
|
||||||
overwrite: overwrite_mode,
|
overwrite: overwrite_mode,
|
||||||
|
@ -199,20 +182,8 @@ pub fn uu_app() -> App<'static, 'static> {
|
||||||
App::new(uucore::util_name())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(backup_control::arguments::backup())
|
||||||
Arg::with_name(options::BACKUP)
|
.arg(backup_control::arguments::backup_no_args())
|
||||||
.long(options::BACKUP)
|
|
||||||
.help("make a backup of each existing destination file")
|
|
||||||
.takes_value(true)
|
|
||||||
.require_equals(true)
|
|
||||||
.min_values(0)
|
|
||||||
.value_name("CONTROL"),
|
|
||||||
)
|
|
||||||
.arg(
|
|
||||||
Arg::with_name(options::BACKUP_NO_ARG)
|
|
||||||
.short(options::BACKUP_NO_ARG)
|
|
||||||
.help("like --backup but does not accept an argument"),
|
|
||||||
)
|
|
||||||
// TODO: opts.arg(
|
// TODO: opts.arg(
|
||||||
// Arg::with_name(("d", "directory", "allow users with appropriate privileges to attempt \
|
// Arg::with_name(("d", "directory", "allow users with appropriate privileges to attempt \
|
||||||
// to make hard links to directories");
|
// to make hard links to directories");
|
||||||
|
@ -250,14 +221,7 @@ pub fn uu_app() -> App<'static, 'static> {
|
||||||
// override added for https://github.com/uutils/coreutils/issues/2359
|
// override added for https://github.com/uutils/coreutils/issues/2359
|
||||||
.overrides_with(options::SYMBOLIC),
|
.overrides_with(options::SYMBOLIC),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(backup_control::arguments::suffix())
|
||||||
Arg::with_name(options::SUFFIX)
|
|
||||||
.short("S")
|
|
||||||
.long(options::SUFFIX)
|
|
||||||
.help("override the usual backup suffix")
|
|
||||||
.value_name("SUFFIX")
|
|
||||||
.takes_value(true),
|
|
||||||
)
|
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(options::TARGET_DIRECTORY)
|
Arg::with_name(options::TARGET_DIRECTORY)
|
||||||
.short("t")
|
.short("t")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue