Skip to content

Commit

Permalink
rename nushell's cp command to cp-old making coreutils the default cp (
Browse files Browse the repository at this point in the history
…nushell#10678)

# Description

This PR renames nushell's `cp` command to `cp-old` to make room for
`ucp` to be renamed to `cp`, making the coreutils version of `cp` the
default for nushell. After some period of time, we should remove
`cp-old` entirely.

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# 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.
-->
  • Loading branch information
fdncred authored and hardfau1t committed Dec 14, 2023
1 parent 31c10e1 commit 5098cfe
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 71 deletions.
33 changes: 9 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ stable = ["default"]
wasi = ["nu-cmd-lang/wasi"]
# NOTE: individual features are also passed to `nu-cmd-lang` that uses them to generate the feature matrix in the `version` command

# Enable to statically link OpenSSL (perl is required, to build OpenSSL https://docs.rs/openssl/latest/openssl/);
# Enable to statically link OpenSSL (perl is required, to build OpenSSL https://docs.rs/openssl/latest/openssl/);
# otherwise the system version will be used. Not enabled by default because it takes a while to build
static-link-openssl = ["dep:openssl", "nu-cmd-lang/static-link-openssl"]

Expand Down Expand Up @@ -164,8 +164,9 @@ bench = false
# To use a development version of a dependency please use a global override here
# changing versions in each sub-crate of the workspace is tedious
[patch.crates-io]
reedline = { git = "https://github.com/nushell/reedline.git", branch = "main"}
reedline = { git = "https://github.com/nushell/reedline.git", branch = "main" }
# nu-ansi-term = {git = "https://github.com/nushell/nu-ansi-term.git", branch = "main"}
uu_cp = { git = "https://github.com/uutils/coreutils.git", branch = "main" }

# Criterion benchmarking setup
# Run all benchmarks with `cargo bench`
Expand Down
6 changes: 3 additions & 3 deletions crates/nu-command/src/filesystem/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ pub struct Cp;

impl Command for Cp {
fn name(&self) -> &str {
"cp"
"cp-old"
}

fn usage(&self) -> &str {
"Copy files."
"Old nushell version of Copy files."
}

fn search_terms(&self) -> Vec<&str> {
vec!["copy", "file", "files"]
}

fn signature(&self) -> Signature {
Signature::build("cp")
Signature::build("cp-old")
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
.required("source", SyntaxShape::GlobPattern, "the place to copy from")
.required("destination", SyntaxShape::Filepath, "the place to copy to")
Expand Down
12 changes: 6 additions & 6 deletions crates/nu-command/src/filesystem/ucp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct UCp;

impl Command for UCp {
fn name(&self) -> &str {
"ucp"
"cp"
}

fn usage(&self) -> &str {
Expand All @@ -39,7 +39,7 @@ impl Command for UCp {
}

fn signature(&self) -> Signature {
Signature::build("ucp")
Signature::build("cp")
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
.switch("recursive", "copy directories recursively", Some('r'))
.switch("verbose", "explicitly state what is being done", Some('v'))
Expand All @@ -63,22 +63,22 @@ impl Command for UCp {
vec![
Example {
description: "Copy myfile to dir_b",
example: "ucp myfile dir_b",
example: "cp myfile dir_b",
result: None,
},
Example {
description: "Recursively copy dir_a to dir_b",
example: "ucp -r dir_a dir_b",
example: "cp -r dir_a dir_b",
result: None,
},
Example {
description: "Recursively copy dir_a to dir_b, and print the feedbacks",
example: "ucp -r -v dir_a dir_b",
example: "cp -r -v dir_a dir_b",
result: None,
},
Example {
description: "Move many files into a directory",
example: "ucp *.txt dir_a",
example: "cp *.txt dir_a",
result: None,
},
]
Expand Down
11 changes: 7 additions & 4 deletions crates/nu-command/tests/commands/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ fn copy_file_and_dir_from_two_parents_up_using_multiple_dots_to_current_dir_recu
})
}

#[ignore = "duplicate test with slight differences in ucp"]
#[test]
fn copy_to_non_existing_dir() {
copy_to_non_existing_dir_impl(false);
Expand All @@ -395,6 +396,7 @@ fn copy_to_non_existing_dir_impl(progress: bool) {
});
}

#[ignore = "duplicate test with slight differences in ucp"]
#[test]
fn copy_dir_contains_symlink_ignored() {
copy_dir_contains_symlink_ignored_impl(false);
Expand Down Expand Up @@ -488,6 +490,7 @@ fn copy_dir_symlink_file_body_not_changed_impl(progress: bool) {
});
}

#[ignore = "duplicate test with slight differences in ucp"]
#[test]
fn copy_identical_file() {
copy_identical_file_impl(false);
Expand Down Expand Up @@ -530,6 +533,7 @@ fn copy_ignores_ansi_impl(progress: bool) {
});
}

#[ignore = "duplicate test with ucp with slight differences"]
#[test]
fn copy_file_not_exists_dst() {
copy_file_not_exists_dst_impl(false);
Expand Down Expand Up @@ -573,13 +577,12 @@ fn copy_file_with_read_permission_impl(progress: bool) {
"cp {} valid.txt invalid_prem.txt",
progress_flag,
);
assert!(
actual.err.contains("invalid_prem.txt")
&& actual.err.contains("copying to destination")
);

assert!(actual.err.contains("invalid_prem.txt") && actual.err.contains("denied"));
});
}

#[ignore = "not implemented with ucp"]
#[test]
fn copy_file_with_update_flag() {
copy_file_with_update_flag_impl(false);
Expand Down
Loading

0 comments on commit 5098cfe

Please sign in to comment.