diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-04-21 08:20:43 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-04-21 09:24:01 +0300 |
commit | afc842c9025e33f2e25716d80ecac07117766457 (patch) | |
tree | c0c563d80cb5d190e5afbd09704055db7ad4a1c1 /src/bin | |
parent | 50258196ee8832ca8d9f02e73babb431248ed025 (diff) | |
download | bumper-rs-afc842c9025e33f2e25716d80ecac07117766457.tar.gz |
refactor: make logging and messages more consistent
Also, report the Debian package version correctly, not just the
upstream part.
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/bumper.rs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/bin/bumper.rs b/src/bin/bumper.rs index b2e9f68..59443e5 100644 --- a/src/bin/bumper.rs +++ b/src/bin/bumper.rs @@ -1,7 +1,8 @@ use bumper::errors::BumperError; use bumper::git; use bumper::project::ProjectKind; -use log::{error, info}; +use log::{debug, error}; +use std::path::{Path, PathBuf}; use std::process::exit; use structopt::StructOpt; @@ -14,20 +15,30 @@ fn main() { fn bumper() -> Result<(), BumperError> { pretty_env_logger::init_custom_env("BUMPER_LOG"); - info!("Bumper starts"); + debug!("Bumper starts"); let opt = Opt::from_args(); - for mut kind in ProjectKind::detect(".")? { - kind.set_version(&opt.version)?; + let cwd = abspath(".")?; + println!("Setting version for project in {}", cwd.display()); + for mut kind in ProjectKind::detect(&cwd)? { + let version = kind.set_version(&opt.version)?; + println!("{} project set to {}", kind.desc(), version); } let msg = format!("Set version to {}", opt.version); git::commit(".", &msg)?; git::tag(".", &opt.version)?; - info!("Bumper ends OK"); + debug!("Bumper ends OK"); Ok(()) } +fn abspath<P: AsRef<Path>>(path: P) -> Result<PathBuf, BumperError> { + let path = path.as_ref(); + path.to_path_buf() + .canonicalize() + .map_err(|err| BumperError::AbsPath(path.to_path_buf(), err)) +} + #[derive(Debug, StructOpt)] struct Opt { #[structopt(help = "version number of new release")] |