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

install: Adapt to modified backup_control interface

This commit is contained in:
Andreas Hartmann 2021-07-21 09:30:00 +02:00 committed by Michael Debertol
parent f2311f87f4
commit ce0d9bce28

View file

@ -17,7 +17,7 @@ use file_diff::diff;
use filetime::{set_file_times, FileTime}; use filetime::{set_file_times, FileTime};
use uucore::backup_control::{self, BackupMode}; use uucore::backup_control::{self, BackupMode};
use uucore::entries::{grp2gid, usr2uid}; use uucore::entries::{grp2gid, usr2uid};
use uucore::error::{FromIo, UError, UIoError, UResult, USimpleError}; use uucore::error::{FromIo, UError, UIoError, UResult};
use uucore::perms::{wrap_chown, Verbosity, VerbosityLevel}; use uucore::perms::{wrap_chown, Verbosity, VerbosityLevel};
use libc::{getegid, geteuid}; use libc::{getegid, geteuid};
@ -154,8 +154,6 @@ static ABOUT: &str = "Copy SOURCE to DEST or multiple SOURCE(s) to the existing
DIRECTORY, while setting permission modes and owner/group"; DIRECTORY, while setting permission modes and owner/group";
static OPT_COMPARE: &str = "compare"; static OPT_COMPARE: &str = "compare";
static OPT_BACKUP: &str = "backup";
static OPT_BACKUP_NO_ARG: &str = "backup2";
static OPT_DIRECTORY: &str = "directory"; static OPT_DIRECTORY: &str = "directory";
static OPT_IGNORED: &str = "ignored"; static OPT_IGNORED: &str = "ignored";
static OPT_CREATE_LEADING: &str = "create-leading"; static OPT_CREATE_LEADING: &str = "create-leading";
@ -165,7 +163,6 @@ static OPT_OWNER: &str = "owner";
static OPT_PRESERVE_TIMESTAMPS: &str = "preserve-timestamps"; static OPT_PRESERVE_TIMESTAMPS: &str = "preserve-timestamps";
static OPT_STRIP: &str = "strip"; static OPT_STRIP: &str = "strip";
static OPT_STRIP_PROGRAM: &str = "strip-program"; static OPT_STRIP_PROGRAM: &str = "strip-program";
static OPT_SUFFIX: &str = "suffix";
static OPT_TARGET_DIRECTORY: &str = "target-directory"; static OPT_TARGET_DIRECTORY: &str = "target-directory";
static OPT_NO_TARGET_DIRECTORY: &str = "no-target-directory"; static OPT_NO_TARGET_DIRECTORY: &str = "no-target-directory";
static OPT_VERBOSE: &str = "verbose"; static OPT_VERBOSE: &str = "verbose";
@ -208,19 +205,10 @@ pub fn uu_app() -> App<'static, 'static> {
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.arg( .arg(
Arg::with_name(OPT_BACKUP) backup_control::arguments::backup()
.long(OPT_BACKUP)
.help("make a backup of each existing destination file")
.takes_value(true)
.require_equals(true)
.min_values(0)
.value_name("CONTROL")
) )
.arg( .arg(
// TODO implement flag backup_control::arguments::backup_no_args()
Arg::with_name(OPT_BACKUP_NO_ARG)
.short("b")
.help("like --backup but does not accept an argument")
) )
.arg( .arg(
Arg::with_name(OPT_IGNORED) Arg::with_name(OPT_IGNORED)
@ -278,9 +266,9 @@ pub fn uu_app() -> App<'static, 'static> {
) )
.arg( .arg(
Arg::with_name(OPT_STRIP) Arg::with_name(OPT_STRIP)
.short("s") .short("s")
.long(OPT_STRIP) .long(OPT_STRIP)
.help("strip symbol tables (no action Windows)") .help("strip symbol tables (no action Windows)")
) )
.arg( .arg(
Arg::with_name(OPT_STRIP_PROGRAM) Arg::with_name(OPT_STRIP_PROGRAM)
@ -289,14 +277,7 @@ pub fn uu_app() -> App<'static, 'static> {
.value_name("PROGRAM") .value_name("PROGRAM")
) )
.arg( .arg(
// TODO implement flag backup_control::arguments::suffix()
Arg::with_name(OPT_SUFFIX)
.short("S")
.long(OPT_SUFFIX)
.help("override the usual backup suffix")
.value_name("SUFFIX")
.takes_value(true)
.min_values(1)
) )
.arg( .arg(
// TODO implement flag // TODO implement flag
@ -386,23 +367,14 @@ fn behavior(matches: &ArgMatches) -> UResult<Behavior> {
None None
}; };
let backup_mode = backup_control::determine_backup_mode( let backup_mode = backup_control::determine_backup_mode(matches)?;
matches.is_present(OPT_BACKUP_NO_ARG),
matches.is_present(OPT_BACKUP),
matches.value_of(OPT_BACKUP),
);
let backup_mode = match backup_mode {
Err(err) => return Err(USimpleError::new(1, err)),
Ok(mode) => mode,
};
let target_dir = matches.value_of(OPT_TARGET_DIRECTORY).map(|d| d.to_owned()); let target_dir = matches.value_of(OPT_TARGET_DIRECTORY).map(|d| d.to_owned());
Ok(Behavior { Ok(Behavior {
main_function, main_function,
specified_mode, specified_mode,
backup_mode, backup_mode,
suffix: backup_control::determine_backup_suffix(matches.value_of(OPT_SUFFIX)), suffix: backup_control::determine_backup_suffix(matches),
owner: matches.value_of(OPT_OWNER).unwrap_or("").to_string(), owner: matches.value_of(OPT_OWNER).unwrap_or("").to_string(),
group: matches.value_of(OPT_GROUP).unwrap_or("").to_string(), group: matches.value_of(OPT_GROUP).unwrap_or("").to_string(),
verbose: matches.is_present(OPT_VERBOSE), verbose: matches.is_present(OPT_VERBOSE),