Merge pull request #3887 from cakebaker/cp_fix_indentation

cp: fix indentation within uu_app()
This commit is contained in:
Sylvestre Ledru 2022-09-02 10:21:07 +02:00 committed by GitHub
commit f21fda46b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -313,165 +313,247 @@ pub fn uu_app<'a>() -> Command<'a> {
.about(ABOUT) .about(ABOUT)
.override_usage(format_usage(USAGE)) .override_usage(format_usage(USAGE))
.infer_long_args(true) .infer_long_args(true)
.arg(Arg::new(options::TARGET_DIRECTORY) .arg(
.short('t') Arg::new(options::TARGET_DIRECTORY)
.conflicts_with(options::NO_TARGET_DIRECTORY) .short('t')
.long(options::TARGET_DIRECTORY) .conflicts_with(options::NO_TARGET_DIRECTORY)
.value_name(options::TARGET_DIRECTORY) .long(options::TARGET_DIRECTORY)
.value_hint(clap::ValueHint::DirPath) .value_name(options::TARGET_DIRECTORY)
.takes_value(true) .value_hint(clap::ValueHint::DirPath)
.validator(|s| { .takes_value(true)
if Path::new(s).is_dir() { .validator(|s| {
return Ok(()); if Path::new(s).is_dir() {
} return Ok(());
Err(format!("'{}' is not a directory", s)) }
}) Err(format!("'{}' is not a directory", s))
.help("copy all SOURCE arguments into target-directory")) })
.arg(Arg::new(options::NO_TARGET_DIRECTORY) .help("copy all SOURCE arguments into target-directory"),
.short('T') )
.long(options::NO_TARGET_DIRECTORY) .arg(
.conflicts_with(options::TARGET_DIRECTORY) Arg::new(options::NO_TARGET_DIRECTORY)
.help("Treat DEST as a regular file and not a directory")) .short('T')
.arg(Arg::new(options::INTERACTIVE) .long(options::NO_TARGET_DIRECTORY)
.short('i') .conflicts_with(options::TARGET_DIRECTORY)
.long(options::INTERACTIVE) .help("Treat DEST as a regular file and not a directory"),
.overrides_with(options::NO_CLOBBER) )
.help("ask before overwriting files")) .arg(
.arg(Arg::new(options::LINK) Arg::new(options::INTERACTIVE)
.short('l') .short('i')
.long(options::LINK) .long(options::INTERACTIVE)
.overrides_with_all(MODE_ARGS) .overrides_with(options::NO_CLOBBER)
.help("hard-link files instead of copying")) .help("ask before overwriting files"),
.arg(Arg::new(options::NO_CLOBBER) )
.short('n') .arg(
.long(options::NO_CLOBBER) Arg::new(options::LINK)
.overrides_with(options::INTERACTIVE) .short('l')
.help("don't overwrite a file that already exists")) .long(options::LINK)
.arg(Arg::new(options::RECURSIVE) .overrides_with_all(MODE_ARGS)
.short('r') .help("hard-link files instead of copying"),
.long(options::RECURSIVE) )
// --archive sets this option .arg(
.help("copy directories recursively")) Arg::new(options::NO_CLOBBER)
.arg(Arg::new(options::RECURSIVE_ALIAS) .short('n')
.short('R') .long(options::NO_CLOBBER)
.help("same as -r")) .overrides_with(options::INTERACTIVE)
.arg(Arg::new(options::STRIP_TRAILING_SLASHES) .help("don't overwrite a file that already exists"),
.long(options::STRIP_TRAILING_SLASHES) )
.help("remove any trailing slashes from each SOURCE argument")) .arg(
.arg(Arg::new(options::VERBOSE) Arg::new(options::RECURSIVE)
.short('v') .short('r')
.long(options::VERBOSE) .long(options::RECURSIVE)
.help("explicitly state what is being done")) // --archive sets this option
.arg(Arg::new(options::SYMBOLIC_LINK) .help("copy directories recursively"),
.short('s') )
.long(options::SYMBOLIC_LINK) .arg(
.overrides_with_all(MODE_ARGS) Arg::new(options::RECURSIVE_ALIAS)
.help("make symbolic links instead of copying")) .short('R')
.arg(Arg::new(options::FORCE) .help("same as -r"),
.short('f') )
.long(options::FORCE) .arg(
.help("if an existing destination file cannot be opened, remove it and \ Arg::new(options::STRIP_TRAILING_SLASHES)
.long(options::STRIP_TRAILING_SLASHES)
.help("remove any trailing slashes from each SOURCE argument"),
)
.arg(
Arg::new(options::VERBOSE)
.short('v')
.long(options::VERBOSE)
.help("explicitly state what is being done"),
)
.arg(
Arg::new(options::SYMBOLIC_LINK)
.short('s')
.long(options::SYMBOLIC_LINK)
.overrides_with_all(MODE_ARGS)
.help("make symbolic links instead of copying"),
)
.arg(
Arg::new(options::FORCE)
.short('f')
.long(options::FORCE)
.help(
"if an existing destination file cannot be opened, remove it and \
try again (this option is ignored when the -n option is also used). \ try again (this option is ignored when the -n option is also used). \
Currently not implemented for Windows.")) Currently not implemented for Windows.",
.arg(Arg::new(options::REMOVE_DESTINATION) ),
.long(options::REMOVE_DESTINATION) )
.overrides_with(options::FORCE) .arg(
.help("remove each existing destination file before attempting to open it \ Arg::new(options::REMOVE_DESTINATION)
(contrast with --force). On Windows, currently only works for writeable files.")) .long(options::REMOVE_DESTINATION)
.overrides_with(options::FORCE)
.help(
"remove each existing destination file before attempting to open it \
(contrast with --force). On Windows, currently only works for \
writeable files.",
),
)
.arg(backup_control::arguments::backup()) .arg(backup_control::arguments::backup())
.arg(backup_control::arguments::backup_no_args()) .arg(backup_control::arguments::backup_no_args())
.arg(backup_control::arguments::suffix()) .arg(backup_control::arguments::suffix())
.arg(Arg::new(options::UPDATE) .arg(
.short('u') Arg::new(options::UPDATE)
.long(options::UPDATE) .short('u')
.help("copy only when the SOURCE file is newer than the destination file \ .long(options::UPDATE)
or when the destination file is missing")) .help(
.arg(Arg::new(options::REFLINK) "copy only when the SOURCE file is newer than the destination file \
.long(options::REFLINK) or when the destination file is missing",
.takes_value(true) ),
.value_name("WHEN") )
.overrides_with_all(MODE_ARGS) .arg(
.help("control clone/CoW copies. See below")) Arg::new(options::REFLINK)
.arg(Arg::new(options::ATTRIBUTES_ONLY) .long(options::REFLINK)
.long(options::ATTRIBUTES_ONLY) .takes_value(true)
.overrides_with_all(MODE_ARGS) .value_name("WHEN")
.help("Don't copy the file data, just the attributes")) .overrides_with_all(MODE_ARGS)
.arg(Arg::new(options::PRESERVE) .help("control clone/CoW copies. See below"),
.long(options::PRESERVE) )
.takes_value(true) .arg(
.multiple_occurrences(true) Arg::new(options::ATTRIBUTES_ONLY)
.use_value_delimiter(true) .long(options::ATTRIBUTES_ONLY)
.value_parser(clap::builder::PossibleValuesParser::new(PRESERVABLE_ATTRIBUTES)) .overrides_with_all(MODE_ARGS)
.min_values(0) .help("Don't copy the file data, just the attributes"),
.value_name("ATTR_LIST") )
.overrides_with_all(&[options::ARCHIVE, options::PRESERVE_DEFAULT_ATTRIBUTES, options::NO_PRESERVE]) .arg(
// -d sets this option Arg::new(options::PRESERVE)
// --archive sets this option .long(options::PRESERVE)
.help("Preserve the specified attributes (default: mode, ownership (unix only), timestamps), \ .takes_value(true)
if possible additional attributes: context, links, xattr, all")) .multiple_occurrences(true)
.arg(Arg::new(options::PRESERVE_DEFAULT_ATTRIBUTES) .use_value_delimiter(true)
.short('p') .value_parser(clap::builder::PossibleValuesParser::new(
.long(options::PRESERVE_DEFAULT_ATTRIBUTES) PRESERVABLE_ATTRIBUTES,
.overrides_with_all(&[options::PRESERVE, options::NO_PRESERVE, options::ARCHIVE]) ))
.help("same as --preserve=mode,ownership(unix only),timestamps")) .min_values(0)
.arg(Arg::new(options::NO_PRESERVE) .value_name("ATTR_LIST")
.long(options::NO_PRESERVE) .overrides_with_all(&[
.takes_value(true) options::ARCHIVE,
.value_name("ATTR_LIST") options::PRESERVE_DEFAULT_ATTRIBUTES,
.overrides_with_all(&[options::PRESERVE_DEFAULT_ATTRIBUTES, options::PRESERVE, options::ARCHIVE]) options::NO_PRESERVE,
.help("don't preserve the specified attributes")) ])
.arg(Arg::new(options::PARENTS) // -d sets this option
.long(options::PARENTS) // --archive sets this option
.alias(options::PARENT) .help(
.help("use full source file name under DIRECTORY")) "Preserve the specified attributes (default: mode, ownership (unix only), \
.arg(Arg::new(options::NO_DEREFERENCE) timestamps), if possible additional attributes: context, links, xattr, all",
.short('P') ),
.long(options::NO_DEREFERENCE) )
.overrides_with(options::DEREFERENCE) .arg(
// -d sets this option Arg::new(options::PRESERVE_DEFAULT_ATTRIBUTES)
.help("never follow symbolic links in SOURCE")) .short('p')
.arg(Arg::new(options::DEREFERENCE) .long(options::PRESERVE_DEFAULT_ATTRIBUTES)
.short('L') .overrides_with_all(&[options::PRESERVE, options::NO_PRESERVE, options::ARCHIVE])
.long(options::DEREFERENCE) .help("same as --preserve=mode,ownership(unix only),timestamps"),
.overrides_with(options::NO_DEREFERENCE) )
.help("always follow symbolic links in SOURCE")) .arg(
.arg(Arg::new(options::ARCHIVE) Arg::new(options::NO_PRESERVE)
.short('a') .long(options::NO_PRESERVE)
.long(options::ARCHIVE) .takes_value(true)
.overrides_with_all(&[options::PRESERVE_DEFAULT_ATTRIBUTES, options::PRESERVE, options::NO_PRESERVE]) .value_name("ATTR_LIST")
.help("Same as -dR --preserve=all")) .overrides_with_all(&[
.arg(Arg::new(options::NO_DEREFERENCE_PRESERVE_LINKS) options::PRESERVE_DEFAULT_ATTRIBUTES,
.short('d') options::PRESERVE,
.help("same as --no-dereference --preserve=links")) options::ARCHIVE,
.arg(Arg::new(options::ONE_FILE_SYSTEM) ])
.short('x') .help("don't preserve the specified attributes"),
.long(options::ONE_FILE_SYSTEM) )
.help("stay on this file system")) .arg(
.arg(Arg::new(options::SPARSE) Arg::new(options::PARENTS)
.long(options::SPARSE) .long(options::PARENTS)
.takes_value(true) .alias(options::PARENT)
.value_name("WHEN") .help("use full source file name under DIRECTORY"),
.value_parser(["never", "auto", "always"]) )
.help("NotImplemented: control creation of sparse files. See below")) .arg(
Arg::new(options::NO_DEREFERENCE)
.short('P')
.long(options::NO_DEREFERENCE)
.overrides_with(options::DEREFERENCE)
// -d sets this option
.help("never follow symbolic links in SOURCE"),
)
.arg(
Arg::new(options::DEREFERENCE)
.short('L')
.long(options::DEREFERENCE)
.overrides_with(options::NO_DEREFERENCE)
.help("always follow symbolic links in SOURCE"),
)
.arg(
Arg::new(options::ARCHIVE)
.short('a')
.long(options::ARCHIVE)
.overrides_with_all(&[
options::PRESERVE_DEFAULT_ATTRIBUTES,
options::PRESERVE,
options::NO_PRESERVE,
])
.help("Same as -dR --preserve=all"),
)
.arg(
Arg::new(options::NO_DEREFERENCE_PRESERVE_LINKS)
.short('d')
.help("same as --no-dereference --preserve=links"),
)
.arg(
Arg::new(options::ONE_FILE_SYSTEM)
.short('x')
.long(options::ONE_FILE_SYSTEM)
.help("stay on this file system"),
)
.arg(
Arg::new(options::SPARSE)
.long(options::SPARSE)
.takes_value(true)
.value_name("WHEN")
.value_parser(["never", "auto", "always"])
.help("NotImplemented: control creation of sparse files. See below"),
)
// TODO: implement the following args // TODO: implement the following args
.arg(Arg::new(options::COPY_CONTENTS) .arg(
.long(options::COPY_CONTENTS) Arg::new(options::COPY_CONTENTS)
.overrides_with(options::ATTRIBUTES_ONLY) .long(options::COPY_CONTENTS)
.help("NotImplemented: copy contents of special files when recursive")) .overrides_with(options::ATTRIBUTES_ONLY)
.arg(Arg::new(options::CONTEXT) .help("NotImplemented: copy contents of special files when recursive"),
.long(options::CONTEXT) )
.takes_value(true) .arg(
.value_name("CTX") Arg::new(options::CONTEXT)
.help("NotImplemented: set SELinux security context of destination file to default type")) .long(options::CONTEXT)
.arg(Arg::new(options::CLI_SYMBOLIC_LINKS) .takes_value(true)
.short('H') .value_name("CTX")
.help("NotImplemented: follow command-line symbolic links in SOURCE")) .help(
"NotImplemented: set SELinux security context of destination file to \
default type",
),
)
.arg(
Arg::new(options::CLI_SYMBOLIC_LINKS)
.short('H')
.help("NotImplemented: follow command-line symbolic links in SOURCE"),
)
// END TODO // END TODO
.arg(
.arg(Arg::new(options::PATHS) Arg::new(options::PATHS)
.multiple_occurrences(true) .multiple_occurrences(true)
.value_hint(clap::ValueHint::AnyPath)) .value_hint(clap::ValueHint::AnyPath),
)
} }
#[uucore::main] #[uucore::main]