From afc842c9025e33f2e25716d80ecac07117766457 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Wed, 21 Apr 2021 08:20:43 +0300 Subject: refactor: make logging and messages more consistent Also, report the Debian package version correctly, not just the upstream part. --- src/project.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/project.rs') diff --git a/src/project.rs b/src/project.rs index e67fefc..655fb23 100644 --- a/src/project.rs +++ b/src/project.rs @@ -2,6 +2,7 @@ use crate::debian::Debian; use crate::errors::BumperError; use crate::python::Python; use crate::rust::Rust; +use log::{debug, info}; use std::path::Path; pub enum ProjectKind { @@ -15,6 +16,8 @@ impl ProjectKind { let dirname = dirname.as_ref(); let mut kinds = vec![]; + debug!("detecting kinds of project in {}", dirname.display()); + if let Ok(p) = Rust::new(dirname) { kinds.push(ProjectKind::Rust(p)); } @@ -30,16 +33,26 @@ impl ProjectKind { if kinds.is_empty() { Err(BumperError::UnknownProjectKind(dirname.to_path_buf())) } else { + for kind in kinds.iter() { + info!("{} project in {}", kind.desc(), dirname.display()); + } Ok(kinds) } } - pub fn set_version(&mut self, version: &str) -> Result<(), BumperError> { + pub fn desc(&self) -> &'static str { match self { + Self::Debian(_) => "Debian package", + Self::Python(_) => "Python", + Self::Rust(_) => "Rust", + } + } + + pub fn set_version(&mut self, version: &str) -> Result { + Ok(match self { Self::Rust(ref mut rust) => rust.set_version(version)?, Self::Debian(ref mut debian) => debian.set_version(version)?, Self::Python(ref mut python) => python.set_version(version)?, - } - Ok(()) + }) } } -- cgit v1.2.1