summaryrefslogtreecommitdiff
path: root/cli/build.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-05-22 15:13:51 +0200
committerLaurenz <laurmaedje@gmail.com>2023-05-22 15:13:51 +0200
commit88553fe3c0459085c8f04e10c7c2ae2501e85b26 (patch)
tree5803dde47c91c0ccd2e8fbf82d33e0f13d65de59 /cli/build.rs
parent8aa0ae197d9f77f77dcf9de46b48a4ef7719d562 (diff)
Tidy up CLI
Diffstat (limited to 'cli/build.rs')
-rw-r--r--cli/build.rs35
1 files changed, 18 insertions, 17 deletions
diff --git a/cli/build.rs b/cli/build.rs
index b6f7d6ee..86325e1d 100644
--- a/cli/build.rs
+++ b/cli/build.rs
@@ -7,23 +7,6 @@ use clap::{CommandFactory, ValueEnum};
use clap_complete::{generate_to, Shell};
use clap_mangen::Man;
-pub fn typst_version() -> String {
- if let Some(version) = option_env!("TYPST_VERSION") {
- return version.to_owned();
- }
-
- let pkg = env!("CARGO_PKG_VERSION");
- let hash = Command::new("git")
- .args(["rev-parse", "HEAD"])
- .output()
- .ok()
- .filter(|output| output.status.success())
- .and_then(|output| String::from_utf8(output.stdout.get(..8)?.into()).ok())
- .unwrap_or_else(|| "unknown hash".into());
-
- format!("{pkg} ({hash})")
-}
-
#[path = "src/args.rs"]
#[allow(dead_code)]
mod args;
@@ -57,3 +40,21 @@ fn main() {
}
}
}
+
+/// Also used by `args.rs`.
+fn typst_version() -> String {
+ if let Some(version) = option_env!("TYPST_VERSION") {
+ return version.to_owned();
+ }
+
+ let pkg = env!("CARGO_PKG_VERSION");
+ let hash = Command::new("git")
+ .args(["rev-parse", "HEAD"])
+ .output()
+ .ok()
+ .filter(|output| output.status.success())
+ .and_then(|output| String::from_utf8(output.stdout.get(..8)?.into()).ok())
+ .unwrap_or_else(|| "unknown hash".into());
+
+ format!("{pkg} ({hash})")
+}