Skip to content

Commit

Permalink
Finished commands
Browse files Browse the repository at this point in the history
  • Loading branch information
x0f5c3 committed Nov 14, 2021
1 parent fcfd766 commit 163d77c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

# v0.8.0 (2021-11-14)
- [Added] persistence and config files

# v0.7.5 (2020-12-30):
- [Added] option to use github api or git

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "go_version_manager"
version = "0.7.0"
version = "0.8.0"
authors = ["x0f5c3 <x0f5c3@tutanota.com>"]
edition = "2018"
description = "A small program to download chosen golang version"
Expand Down
6 changes: 3 additions & 3 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl Update {
latest.download(None, workers)
}
}
} else if check_writable(&c.install_path)? {
} else if check_writable(c.install_path.parent().ok_or(Error::PathBufErr)?)? {
latest.download(None, workers)
} else {
Err(Error::PathBufErr)
Expand Down Expand Up @@ -160,7 +160,7 @@ impl Install {
versions.latest()
}
};
if check_writable(&c.install_path)? {
if check_writable(c.install_path.parent().ok_or(Error::PathBufErr)?)? {
let res = golang.download(None, workers)?;
if let Downloaded::Mem(v) = res {
let mut dec = ToDecompress::new(Cursor::new(v))?;
Expand All @@ -175,7 +175,7 @@ impl Install {
Err(Error::PathBufErr)
}
} else {
Err(Error::PathBufErr)
Err(Error::NOPerm)
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ pub enum Error {
ZIPErr(#[from] zip::result::ZipError),
#[error("ENV error: {0}")]
VARErr(#[from] std::env::VarError),
#[error("Permission denied, restart the program as root")]
NOPerm,
}
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ use versions::SemVer;
#[paw::main]
#[quit::main]
fn main(opt: Command) -> Result<()> {
#[cfg(debug_assertions)]
let now = std::time::Instant::now();
setup_panic!();
init_consts();
pretty_env_logger::init();
opt.run()?;
let res = opt.run();
if let Err(e) = res {
paris::error!("Error: {}", e);
}
#[cfg(debug_assertions)]
paris::info!("Execution time: {}s", now.elapsed().as_secs_f64());
Ok(())
}
Expand Down

0 comments on commit 163d77c

Please sign in to comment.