mirror of
https://github.com/nushell/nushell
synced 2024-12-26 04:53:09 +00:00
implement --link and --symbolic-link
This commit is contained in:
parent
c3e99bb597
commit
0c812bfbbf
1 changed files with 14 additions and 3 deletions
|
@ -47,6 +47,8 @@ impl Command for UCp {
|
||||||
)
|
)
|
||||||
.switch("progress", "display a progress bar", Some('p'))
|
.switch("progress", "display a progress bar", Some('p'))
|
||||||
.switch("no-clobber", "do not overwrite an existing file", Some('n'))
|
.switch("no-clobber", "do not overwrite an existing file", Some('n'))
|
||||||
|
.switch("link", "hard-link files instead of copying", Some('l'))
|
||||||
|
.switch("symbolic-link", "make symbolic links instead of copying", Some('s'))
|
||||||
.named(
|
.named(
|
||||||
"preserve",
|
"preserve",
|
||||||
SyntaxShape::List(Box::new(SyntaxShape::String)),
|
SyntaxShape::List(Box::new(SyntaxShape::String)),
|
||||||
|
@ -109,10 +111,19 @@ impl Command for UCp {
|
||||||
_input: PipelineData,
|
_input: PipelineData,
|
||||||
) -> Result<PipelineData, ShellError> {
|
) -> Result<PipelineData, ShellError> {
|
||||||
let interactive = call.has_flag(engine_state, stack, "interactive")?;
|
let interactive = call.has_flag(engine_state, stack, "interactive")?;
|
||||||
let (update, copy_mode) = if call.has_flag(engine_state, stack, "update")? {
|
let update = if call.has_flag(engine_state, stack, "update")? {
|
||||||
(UpdateMode::ReplaceIfOlder, CopyMode::Update)
|
UpdateMode::ReplaceIfOlder
|
||||||
} else {
|
} else {
|
||||||
(UpdateMode::ReplaceAll, CopyMode::Copy)
|
UpdateMode::ReplaceAll
|
||||||
|
};
|
||||||
|
let copy_mode = if call.has_flag(engine_state, stack, "link")? {
|
||||||
|
CopyMode::Link
|
||||||
|
} else if call.has_flag(engine_state, stack, "symbolic-link")? {
|
||||||
|
CopyMode::SymLink
|
||||||
|
} else if call.has_flag(engine_state, stack, "update")? {
|
||||||
|
CopyMode::Update
|
||||||
|
} else {
|
||||||
|
CopyMode::Copy
|
||||||
};
|
};
|
||||||
|
|
||||||
let force = call.has_flag(engine_state, stack, "force")?;
|
let force = call.has_flag(engine_state, stack, "force")?;
|
||||||
|
|
Loading…
Reference in a new issue