Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename cargo-update to cargo-updat #413

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,11 @@ name = "cargo-generate-lockfile"
test = false
doc = false

# Note that this is named `updat`, not `update`, this is sadly because windows
# will require elevated privileges for any executable with the string "update"
# in its name.
[[bin]]
name = "cargo-update"
name = "cargo-updat"
test = false
doc = false

Expand Down
File renamed without changes.
13 changes: 10 additions & 3 deletions src/bin/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,17 @@ fn execute(flags: Flags, shell: &mut MultiShell) -> CliResult<Option<()>> {
shell.set_verbose(flags.flag_verbose);
if flags.flag_list {
println!("Installed Commands:");
for command in list_commands().iter() {
for command in list_commands().move_iter() {
let command = if command.as_slice() == "updat" {
"update".to_string()
} else {
command
};
println!(" {}", command);
// TODO: it might be helpful to add result of -h to each command.
};
return Ok(None)
}

let mut args = flags.arg_args.clone();
args.insert(0, flags.arg_command.clone());
match flags.arg_command.as_slice() {
Expand Down Expand Up @@ -109,7 +114,8 @@ fn execute(flags: Flags, shell: &mut MultiShell) -> CliResult<Option<()>> {
Ok(None)
}

fn execute_subcommand(cmd: &str, is_help: bool, flags: &Flags, shell: &mut MultiShell) -> () {
fn execute_subcommand(cmd: &str, is_help: bool, flags: &Flags,
shell: &mut MultiShell) -> () {
match find_command(cmd) {
Some(command) => {
let mut command = Command::new(command);
Expand Down Expand Up @@ -183,6 +189,7 @@ fn is_executable(path: &Path) -> bool {

/// Get `Command` to run given command.
fn find_command(cmd: &str) -> Option<Path> {
let cmd = if cmd == "update" {"updat"} else {cmd};
let command_exe = format!("cargo-{}{}", cmd, os::consts::EXE_SUFFIX);
let dirs = list_command_directory();
let mut command_paths = dirs.iter().map(|dir| dir.join(command_exe.as_slice()));
Expand Down
12 changes: 6 additions & 6 deletions tests/test_cargo_compile_git_deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ test!(recompilation {
FRESH, git_project.url(),
FRESH, p.url())));

assert_that(p.process(cargo_dir().join("cargo-update")),
assert_that(p.process(cargo_dir().join("cargo")).arg("update"),
execs().with_stdout(format!("{} git repository `{}`",
UPDATING,
git_project.url())));
Expand All @@ -574,7 +574,7 @@ test!(recompilation {
p.root().move_into_the_past().assert();

// Update the dependency and carry on!
assert_that(p.process(cargo_dir().join("cargo-update")),
assert_that(p.process(cargo_dir().join("cargo")).arg("update"),
execs().with_stdout(format!("{} git repository `{}`",
UPDATING,
git_project.url())));
Expand Down Expand Up @@ -665,7 +665,7 @@ test!(update_with_shared_deps {

timer::sleep(Duration::milliseconds(1000));

assert_that(p.process(cargo_dir().join("cargo-update")).arg("dep1"),
assert_that(p.process(cargo_dir().join("cargo")).arg("update").arg("dep1"),
execs().with_stdout(format!("{} git repository `{}`",
UPDATING,
git_project.url())));
Expand All @@ -681,7 +681,7 @@ test!(update_with_shared_deps {
compiling = COMPILING, dir = p.url())));

// We should be able to update transitive deps
assert_that(p.process(cargo_dir().join("cargo-update")).arg("bar"),
assert_that(p.process(cargo_dir().join("cargo")).arg("update").arg("bar"),
execs().with_stdout(format!("{} git repository `{}`",
UPDATING,
git_project.url())));
Expand Down Expand Up @@ -789,7 +789,7 @@ test!(two_deps_only_update_one {
git1.process("git").args(["commit", "-m", "test"]).exec_with_output()
.assert();

assert_that(project.process(cargo_dir().join("cargo-update")).arg("dep1"),
assert_that(project.process(cargo_dir().join("cargo")).arg("update").arg("dep1"),
execs()
.with_stdout(format!("{} git repository `{}`\n",
UPDATING, git1.url()))
Expand Down Expand Up @@ -939,7 +939,7 @@ test!(dep_with_changed_submodule {

timer::sleep(Duration::milliseconds(1000));
// Update the dependency and carry on!
assert_that(project.process(cargo_dir().join("cargo-update")), execs()
assert_that(project.process(cargo_dir().join("cargo")).arg("update"), execs()
.with_stderr("")
.with_stdout(format!("{} git repository `{}`",
UPDATING,
Expand Down