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

Housekeeping - nothing to see here, move along #90

Merged
merged 4 commits into from
Aug 14, 2018
Merged
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
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ exclude = ["*.enc"]

[dependencies]
serde_derive = "1.0"
lazy_static = "1.0"
lazy_static = "1.1.0"
array_tool = "1.0"
tabwriter = "1.0"
tabwriter = "1.1"
lazysort = "0.2"
regex = "0.2"
regex = "1.0.2"
serde = "1.0"
git2 = "0.6"
clap = "2.30"
git2 = "0.7.5"
clap = "2.32"
json = "0.11"
toml = "0.4"
url = "1.7"
dirs = "1.0.2"

[dependencies.semver]
version = "0.9"
Expand Down
1 change: 1 addition & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ fn_args_paren_newline = false
fn_args_density = "Compressed"
struct_trailing_comma = "Always"
wrap_comments = true
reorder_imports = false
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
//! Updated 1 package.
//! ```

#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]

#[macro_use]
extern crate serde_derive;
Expand All @@ -316,6 +317,7 @@ extern crate clap;
extern crate toml;
extern crate json;
extern crate url;
extern crate dirs;

mod options;

Expand Down
14 changes: 7 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn actual_main() -> Result<(), i32> {
if !search_res.success() {
return Err(search_res.code().unwrap_or(-1));
}
println!("");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this code pre-dates zero-arg writeln!()s :Р
Good catch 👍

println!();
}

let registry = cargo_update::ops::get_index_path(&opts.cargo_dir.1);
Expand Down Expand Up @@ -103,7 +103,7 @@ fn actual_main() -> Result<(), i32> {
})
.unwrap();
}
writeln!(out, "").unwrap();
writeln!(out).unwrap();
out.flush().unwrap();
}

Expand Down Expand Up @@ -151,7 +151,7 @@ fn actual_main() -> Result<(), i32> {
}
.unwrap();

println!("");
println!();
if !install_res.success() {
if cfg!(target_os = "windows") && package.version.is_some() && package.name == "cargo-update" {
restore_cargo_update_exec(package.version.as_ref().unwrap());
Expand All @@ -170,7 +170,7 @@ fn actual_main() -> Result<(), i32> {
}
});

println!("");
println!();
println!("Updated {} package{}.", success_n, if success_n == 1 { "" } else { "s" });
if !errored.is_empty() && result.is_some() {
println!("Failed to update {}.", &errored.iter().fold("".to_string(), |s, e| s + ", " + e)[2..]);
Expand Down Expand Up @@ -208,7 +208,7 @@ fn actual_main() -> Result<(), i32> {
if package.needs_update() { "Yes" } else { "No" })
.unwrap();
}
writeln!(out, "").unwrap();
writeln!(out).unwrap();
out.flush().unwrap();
}

Expand Down Expand Up @@ -250,7 +250,7 @@ fn actual_main() -> Result<(), i32> {
}
.unwrap();

println!("");
println!();
if !install_res.success() {
if cfg!(target_os = "windows") && package.name == "cargo-update" {
restore_cargo_update_exec(&package.id.to_string());
Expand All @@ -269,7 +269,7 @@ fn actual_main() -> Result<(), i32> {
}
});

println!("");
println!();
println!("Updated {} git package{}.", success_n, if success_n == 1 { "" } else { "s" });
if !errored.is_empty() && result.is_some() {
println!("Failed to update {}.", &errored.iter().fold("".to_string(), |s, e| s + ", " + e)[2..]);
Expand Down
13 changes: 7 additions & 6 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
use self::super::ops::{PackageFilterElement, ConfigOperation};
use semver::{VersionReq as SemverReq, Version as Semver};
use clap::{self, AppSettings, SubCommand, App, Arg};
use std::env::{self, home_dir};
use std::env;
use array_tool::vec::Uniq;
use std::path::PathBuf;
use std::str::FromStr;
use std::fs;
use dirs::home_dir;


/// Representation of the application's all configurable values.
Expand Down Expand Up @@ -73,9 +74,9 @@ impl Options {
.about("A cargo subcommand for checking and applying updates to installed executables")
.args(&[Arg::from_usage("-c --cargo-dir=[CARGO_DIR] 'The cargo home directory. Default: $CARGO_HOME or $HOME/.cargo'")
.visible_alias("root")
.validator(|s| existing_dir_validator("Cargo", s)),
.validator(|s| existing_dir_validator("Cargo", &s)),
Arg::from_usage("-t --temp-dir=[TEMP_DIR] 'The temporary directory. Default: $TEMP/cargo-update'")
.validator(|s| existing_dir_validator("Temporary", s)),
.validator(|s| existing_dir_validator("Temporary", &s)),
Arg::from_usage("-a --all 'Update all packages'").conflicts_with("PACKAGE"),
Arg::from_usage("-l --list 'Don't update packages, only list and check if they need an update'"),
Arg::from_usage("-f --force 'Update all packages regardless if they need updating'"),
Expand Down Expand Up @@ -145,7 +146,7 @@ impl ConfigOptions {
.author(crate_authors!("\n"))
.about("A cargo subcommand for checking and applying updates to installed executables -- configuration")
.args(&[Arg::from_usage("-c --cargo-dir=[CARGO_DIR] 'The cargo home directory. Default: $CARGO_HOME or $HOME/.cargo'")
.validator(|s| existing_dir_validator("Cargo", s)),
.validator(|s| existing_dir_validator("Cargo", &s)),
Arg::from_usage("-t --toolchain=[TOOLCHAIN] 'Toolchain to use or empty for default'"),
Arg::from_usage("-f --feature=[FEATURE]... 'Feature to enable'"),
Arg::from_usage("-n --no-feature=[DISABLED_FEATURE]... 'Feature to disable'"),
Expand Down Expand Up @@ -224,8 +225,8 @@ fn cargo_dir() -> (String, PathBuf) {
}
}

fn existing_dir_validator(label: &str, s: String) -> Result<(), String> {
fs::canonicalize(&s).map(|_| ()).map_err(|_| format!("{} directory \"{}\" not found", label, s))
fn existing_dir_validator(label: &str, s: &str) -> Result<(), String> {
fs::canonicalize(s).map(|_| ()).map_err(|_| format!("{} directory \"{}\" not found", label, s))
}

fn package_parse(s: String) -> Result<(String, Option<Semver>), String> {
Expand Down