use const format for version string
This commit is contained in:
Generated
+27
@@ -76,6 +76,26 @@ dependencies = [
|
||||
"os_str_bytes",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "const_format"
|
||||
version = "0.2.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7309d9b4d3d2c0641e018d449232f2e28f1b22933c137f157d3dbc14228b8c0e"
|
||||
dependencies = [
|
||||
"const_format_proc_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "const_format_proc_macros"
|
||||
version = "0.2.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d897f47bf7270cf70d370f8f98c1abb6d2d4cf60a6845d30e05bfb90c6568650"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.2.8"
|
||||
@@ -192,6 +212,7 @@ dependencies = [
|
||||
"alpm",
|
||||
"anyhow",
|
||||
"clap",
|
||||
"const_format",
|
||||
"pacdef_macros",
|
||||
"path-absolutize",
|
||||
"regex",
|
||||
@@ -372,6 +393,12 @@ version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
|
||||
|
||||
[[package]]
|
||||
name = "unsafe-libyaml"
|
||||
version = "0.2.5"
|
||||
|
||||
@@ -13,6 +13,7 @@ categories = ["command-line-utilities"]
|
||||
alpm = "2.2"
|
||||
anyhow = {workspace = true}
|
||||
clap = "4.1"
|
||||
const_format = { version = "0.2", default-features = false }
|
||||
path-absolutize = "3.0"
|
||||
regex = "1.7"
|
||||
termios = "0.3"
|
||||
@@ -23,3 +24,4 @@ serde_derive = "1.0"
|
||||
serde = "1.0"
|
||||
|
||||
pacdef_macros = {path = "../pacdef_macros", version = "0.1"}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ use std::path::Path;
|
||||
|
||||
use anyhow::{anyhow, bail, ensure, Context, Result};
|
||||
use clap::ArgMatches;
|
||||
use const_format::formatcp;
|
||||
|
||||
use crate::action::*;
|
||||
use crate::args;
|
||||
@@ -338,11 +339,12 @@ fn show_error(error: &anyhow::Error, backend: &dyn Backend) {
|
||||
}
|
||||
|
||||
pub const fn get_version_string() -> &'static str {
|
||||
concat!(
|
||||
"pacdef, version: ",
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
" (",
|
||||
env!("GIT_HASH"),
|
||||
")",
|
||||
)
|
||||
const VERSION: &str = concat!("pacdef, version: ", env!("CARGO_PKG_VERSION"));
|
||||
const HASH: &str = env!("GIT_HASH");
|
||||
|
||||
if HASH.is_empty() {
|
||||
VERSION
|
||||
} else {
|
||||
formatcp!("{VERSION} ({HASH})")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user