add proper version string
This commit is contained in:
Generated
+1
-1
@@ -182,7 +182,7 @@ checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pacdef"
|
name = "pacdef"
|
||||||
version = "0.1.0"
|
version = "1.0.0-alpha1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alpm",
|
"alpm",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "pacdef"
|
name = "pacdef"
|
||||||
version = "0.1.0"
|
version = "1.0.0-alpha1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
use std::process::Command;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let output = Command::new("git")
|
||||||
|
.args(["rev-parse", "--short", "HEAD"])
|
||||||
|
.output()
|
||||||
|
.unwrap();
|
||||||
|
let git_hash = String::from_utf8(output.stdout).unwrap();
|
||||||
|
println!("cargo:rustc-env=GIT_HASH={git_hash}");
|
||||||
|
}
|
||||||
+2
-1
@@ -4,11 +4,12 @@ use clap::{Arg, ArgMatches, Command};
|
|||||||
use path_absolutize::Absolutize;
|
use path_absolutize::Absolutize;
|
||||||
|
|
||||||
use crate::action::*;
|
use crate::action::*;
|
||||||
|
use crate::core::get_version_string;
|
||||||
|
|
||||||
fn get_arg_parser() -> Command {
|
fn get_arg_parser() -> Command {
|
||||||
Command::new("pacdef")
|
Command::new("pacdef")
|
||||||
.about("declarative package manager for Arch Linux")
|
.about("declarative package manager for Arch Linux")
|
||||||
.version("1.0.0-alpha")
|
.version(get_version_string())
|
||||||
.subcommand_required(true)
|
.subcommand_required(true)
|
||||||
.arg_required_else_help(true)
|
.arg_required_else_help(true)
|
||||||
.subcommand(Command::new(CLEAN).about("remove unmanaged packages"))
|
.subcommand(Command::new(CLEAN).about("remove unmanaged packages"))
|
||||||
|
|||||||
+11
-1
@@ -136,7 +136,7 @@ impl Pacdef {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn show_version(self) {
|
fn show_version(self) {
|
||||||
println!("pacdef, version: {}", env!("CARGO_PKG_VERSION"));
|
println!("{}", get_version_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_unmanaged_packages(mut self) {
|
fn show_unmanaged_packages(mut self) {
|
||||||
@@ -289,3 +289,13 @@ fn show_error(error: anyhow::Error, backend: Box<dyn Backend>) {
|
|||||||
None => println!("WARNING: skipping backend '{section}': {error}"),
|
None => println!("WARNING: skipping backend '{section}': {error}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) const fn get_version_string() -> &'static str {
|
||||||
|
concat!(
|
||||||
|
"pacdef, version: ",
|
||||||
|
env!("CARGO_PKG_VERSION"),
|
||||||
|
" (",
|
||||||
|
env!("GIT_HASH"),
|
||||||
|
")",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user