forked from extern/nushell
rm
: enable trash flag on android and ios platrofm (#8871)
# Description As title, enable trash flag on all platforms make `rm` more portable across different platforms, but `-t` will do nothing. Fixes: #8104 # User-Facing Changes Na # Tests + Formatting It's hard to add tests because we don't run tests for android and ios platforms. # After Submitting <!-- If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. --> --------- Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
This commit is contained in:
parent
4da7bbbb59
commit
ad90b6e5f3
@ -50,21 +50,15 @@ impl Command for Rm {
|
|||||||
"filename",
|
"filename",
|
||||||
SyntaxShape::Filepath,
|
SyntaxShape::Filepath,
|
||||||
"the path of the file you want to remove",
|
"the path of the file you want to remove",
|
||||||
);
|
)
|
||||||
#[cfg(all(
|
|
||||||
feature = "trash-support",
|
|
||||||
not(target_os = "android"),
|
|
||||||
not(target_os = "ios")
|
|
||||||
))]
|
|
||||||
let sig = sig
|
|
||||||
.switch(
|
.switch(
|
||||||
"trash",
|
"trash",
|
||||||
"move to the platform's trash instead of permanently deleting",
|
"move to the platform's trash instead of permanently deleting. not used on android and ios",
|
||||||
Some('t'),
|
Some('t'),
|
||||||
)
|
)
|
||||||
.switch(
|
.switch(
|
||||||
"permanent",
|
"permanent",
|
||||||
"delete permanently, ignoring the 'always_trash' config option",
|
"delete permanently, ignoring the 'always_trash' config option. always enabled on android and ios",
|
||||||
Some('p'),
|
Some('p'),
|
||||||
);
|
);
|
||||||
sig.switch("recursive", "delete subdirectories recursively", Some('r'))
|
sig.switch("recursive", "delete subdirectories recursively", Some('r'))
|
||||||
@ -169,18 +163,13 @@ fn rm(
|
|||||||
|
|
||||||
let rm_always_trash = config.rm_always_trash;
|
let rm_always_trash = config.rm_always_trash;
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(not(feature = "trash-support"))]
|
||||||
not(feature = "trash-support"),
|
|
||||||
target_os = "android",
|
|
||||||
target_os = "ios"
|
|
||||||
))]
|
|
||||||
{
|
{
|
||||||
if rm_always_trash {
|
if rm_always_trash {
|
||||||
return Err(ShellError::GenericError(
|
return Err(ShellError::GenericError(
|
||||||
"Cannot execute `rm`; the current configuration specifies \
|
"Cannot execute `rm`; the current configuration specifies \
|
||||||
`always_trash = true`, but the current nu executable was not \
|
`always_trash = true`, but the current nu executable was not \
|
||||||
built with feature `trash_support` or trash is not supported on \
|
built with feature `trash_support`."
|
||||||
your platform."
|
|
||||||
.into(),
|
.into(),
|
||||||
"trash required to be true but not supported".into(),
|
"trash required to be true but not supported".into(),
|
||||||
Some(span),
|
Some(span),
|
||||||
@ -189,8 +178,7 @@ fn rm(
|
|||||||
));
|
));
|
||||||
} else if trash {
|
} else if trash {
|
||||||
return Err(ShellError::GenericError(
|
return Err(ShellError::GenericError(
|
||||||
"Cannot execute `rm` with option `--trash`; feature `trash-support` not \
|
"Cannot execute `rm` with option `--trash`; feature `trash-support` not enabled"
|
||||||
enabled or trash is not supported on your platform"
|
|
||||||
.into(),
|
.into(),
|
||||||
"this option is only available if nu is built with the `trash-support` feature"
|
"this option is only available if nu is built with the `trash-support` feature"
|
||||||
.into(),
|
.into(),
|
||||||
|
Loading…
Reference in New Issue
Block a user