playdoobs 0.2.0

Service and matching CLI application for controlling the currently active MPRIS2 player
Documentation
use std::env;
use std::error::Error;

use vergen_gitcl::{Emitter, Gitcl};

fn main() -> Result<(), Box<dyn Error>> {
    // update the env vars in flake.nix and lib.rs if we change this
    let gitcl = Gitcl::builder()
        .commit_date(true)
        .describe(false, true, None)
        .build();
    Emitter::default()
        .add_instructions(&gitcl)?
        .emit_and_set()?;

    emit_version();

    Ok(())
}

/// The playdoobs library version in the format `<version> (<date>, <commit>)`.
/// `VERGEN_GIT_*` vars are not set in published crates, so only show the pkg version then
fn emit_version() {
    let version = env::var("CARGO_PKG_VERSION").expect("CARGO_PKG_VERSION must be set");
    // extra for git repo checkout (non-published crate)
    let extra = if let Ok(date) = env::var("VERGEN_GIT_COMMIT_DATE") {
        format!(
            " ({date}, {})",
            env::var("VERGEN_GIT_DESCRIBE").expect("describe must be set if commit date is set")
        )
    } else {
        String::new()
    };

    println!("cargo:rustc-env=APP_VERSION={version}{extra}");
}