2022-09-25 09:59:19 +01:00
|
|
|
//! Integration with `clap`
|
|
|
|
|
|
|
|
use clap::Parser;
|
|
|
|
|
2024-03-12 03:11:59 +00:00
|
|
|
/// Returns the current version of the crate with extra info if supplied
|
|
|
|
///
|
|
|
|
/// Set the environment variable `CONDUIT_VERSION_EXTRA` to any UTF-8 string to
|
|
|
|
/// include it in parenthesis after the SemVer version. A common value are git
|
|
|
|
/// commit hashes.
|
|
|
|
fn version() -> String {
|
|
|
|
let cargo_pkg_version = env!("CARGO_PKG_VERSION");
|
|
|
|
|
|
|
|
match option_env!("CONDUIT_VERSION_EXTRA") {
|
|
|
|
Some(x) => format!("{} ({})", cargo_pkg_version, x),
|
|
|
|
None => cargo_pkg_version.to_owned(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-25 09:59:19 +01:00
|
|
|
/// Command line arguments
|
|
|
|
#[derive(Parser)]
|
2024-03-12 03:11:59 +00:00
|
|
|
#[clap(about, version = version())]
|
2022-09-25 09:59:19 +01:00
|
|
|
pub struct Args {}
|
|
|
|
|
|
|
|
/// Parse command line arguments into structured data
|
|
|
|
pub fn parse() -> Args {
|
|
|
|
Args::parse()
|
|
|
|
}
|