Skip to content

Commit

Permalink
Need to debug'
Browse files Browse the repository at this point in the history
  • Loading branch information
x0f5c3 committed Apr 11, 2022
1 parent 7d4d891 commit 4d57ece
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 25 deletions.
140 changes: 128 additions & 12 deletions Cargo.lock

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

10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ regex = "*"
toml = { version = "0.5.8", features = ["preserve_order"] }
shadow-rs = "0.11.0"
which = "4.2.5"
tracing-appender = "0.2.2"
tracing-unwrap = "0.9.2"

[dependencies.tracing-subscriber]
version = "0.3.11"
features = ["local-time"]

[dependencies.tracing]
version = "0.1.33"
features = ["log"]

[dependencies.semver]
version = "1.0.7"
Expand Down
12 changes: 6 additions & 6 deletions src/goversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ impl GoVersions {
} else {
&VERSION_LIST
};
if path.exists() {
let to_cmp = Self::from_file(path)?;
if to_cmp.latest.version == latest.version {
return Ok(to_cmp);
}
}
// if path.exists() {
// let to_cmp = Self::from_file(path)?;
// if to_cmp.latest.version == latest.version {
// return Ok(to_cmp);
// }
// }
let mut vers = Self::download_versions()?;
vers.par_sort_unstable_by(|a, b| b.version.cmp(&a.version));
let latest = vers.first().cloned().ok_or(Error::NoVersion)?;
Expand Down
19 changes: 12 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,32 @@ pub(crate) use utils::{ask_for_version, init_consts};

use crate::commands::Opt;
use crate::consts::FILE_EXT;
use crate::goversion::Downloaded;
use crate::goversion::GoVersions;
use crate::goversion::{Downloaded, GoVersion};
use crate::utils::check_and_ask;

use anyhow::Result;

/// Reads output path from command line arguments
/// and downloads latest golang version to it
#[clap::main]
#[quit::main]
fn main(opt: Opt) -> Result<()> {
fn main() -> Result<()> {
#[cfg(debug_assertions)]
let now = std::time::Instant::now();
setup_panic!();
init_consts();
pretty_env_logger::init();
check_and_ask(&Term::stdout())?;
let res = opt.run();
if let Err(e) = res {
paris::error!("Error: {}", e);
}
// let res = opt.run();
// if let Err(e) = res {
// paris::error!("Error: {}", e);
// }
let raw = GoVersions::raw_git_versions()?;
let parsed = GoVersions::new(None)?;
let latest = GoVersions::download_latest()?;
paris::log!("Raw versions: {:?}", raw);
paris::log!("Parsed versions: {:?}", parsed);
paris::log!("Latest: {:?}", latest);
#[cfg(debug_assertions)]
paris::info!("Execution time: {}s", now.elapsed().as_secs_f64());
Ok(())
Expand Down

0 comments on commit 4d57ece

Please sign in to comment.