Use built to determine version information

This commit is contained in:
Dustin J. Mitchell
2021-06-07 15:26:41 -04:00
parent 0c43f82176
commit 6c9ba48674
5 changed files with 104 additions and 35 deletions

View File

@@ -1,13 +1,18 @@
use crate::built_info;
use termcolor::{ColorSpec, WriteColor};
pub(crate) fn execute<W: WriteColor>(w: &mut W) -> Result<(), crate::Error> {
write!(w, "TaskChampion ")?;
w.set_color(ColorSpec::new().set_bold(true))?;
write!(w, "{}", env!("CARGO_PKG_VERSION"))?;
write!(w, "{}", built_info::PKG_VERSION)?;
w.reset()?;
if let Some(h) = option_env!("TC_GIT_REV") {
write!(w, " (git rev: {})", h)?;
if let (Some(version), Some(dirty)) = (built_info::GIT_VERSION, built_info::GIT_DIRTY) {
if dirty {
write!(w, " (git version: {} with un-committed changes)", version)?;
} else {
write!(w, " (git version: {})", version)?;
};
}
writeln!(w)?;
Ok(())