show build details on About screen

pull/14/head
dvkt 4 years ago
parent 1d9a2b0f01
commit af449a6402

@ -1,6 +1,26 @@
use std::{env, process};
fn main() {
println!("cargo:rustc-env=PLATFORM={}", env::var("TARGET").unwrap());
println!("cargo:rustc-env=BUILD_DATE={}", sh("date"));
println!(
"cargo:rustc-env=PLATFORM={}",
std::env::var("TARGET").unwrap()
);
"cargo:rustc-env=GIT_REF={}",
sh("git rev-parse --short HEAD")
)
}
fn sh(args: &str) -> String {
let args: Vec<&str> = args.split(" ").collect();
let cmd = args[0];
let args: Vec<_> = args.iter().skip(1).collect();
if let Ok(output) = process::Command::new(cmd).args(&args).output() {
if !output.status.success() {
eprintln!("Error running {} {:?}", cmd, args);
process::exit(1);
}
String::from_utf8(output.stdout).unwrap()
} else {
String::new()
}
}

@ -1,4 +1,3 @@
use native_tls::TlsConnector;
use std::{
io::{Read, Result, Write},
net::TcpStream,
@ -8,6 +7,9 @@ use std::{
};
use termion::input::TermRead;
#[cfg(feature = "tls")]
use native_tls::TlsConnector;
mod r#type;
pub use self::r#type::Type;

@ -6,12 +6,20 @@ pub fn lookup(name: &str) -> Option<String> {
"" | "/" | "home" | "home/" => format!("{}{}", HEADER, START),
"history" => history::as_raw_menu(),
"bookmarks" => bookmarks::as_raw_menu(),
"about" => format!("{}{}", HEADER, ABOUT.replace("{version}", crate::VERSION)),
"help/keys" => format!("{}{}", HEADER, KEYS),
"help/nav" => format!("{}{}", HEADER, NAV),
"help/types" => format!("{}{}", HEADER, TYPES),
"help/bookmarks" => format!("{}{}", HEADER, BOOKMARKS),
"help/history" => format!("{}{}", HEADER, HISTORY),
"about" => format!(
"{}{}",
HEADER,
ABOUT
.replace("{build-date}", crate::BUILD_DATE)
.replace("{git-ref}", crate::GIT_REF)
.replace("{tls-support}", crate::TLS_SUPPORT)
.replace("{version}", crate::VERSION)
),
"help" | "help/" => format!(
"{}{}",
HEADER,
@ -212,6 +220,12 @@ i
const ABOUT: &str = "
i ~ version: v{version} ~
i
1phetch's gopherhole /phetch phkt.io
hphetch's webpage URL:https://github.com/dvkt/phetch
0MIT license /MIT License gopherpedia.com
i
i ~ * ~
i
ispecial thanks to:
i
ikseistrup - major help with
@ -225,7 +239,8 @@ i add some \x1b[95mcolor
i
i ~ * ~
i
1phetch's gopherhole /phetch phkt.io
0phetch uses the MIT license /MIT License gopherpedia.com
hwebpage: github.com/dvkt/phetch URL:https://github.com/dvkt/phetch
itls: {tls-support}
iref: {git-ref}
ibuilt: {build-date}
i
";

@ -13,4 +13,11 @@ pub mod ui;
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const PLATFORM: &str = env!("PLATFORM");
pub const GIT_REF: &str = env!("GIT_REF");
pub const BUILD_DATE: &str = env!("BUILD_DATE");
pub const BUG_URL: &str = "https://github.com/dvkt/phetch/issues/new";
#[cfg(feature = "tls")]
pub const TLS_SUPPORT: &str = "enabled";
#[cfg(not(feature = "tls"))]
pub const TLS_SUPPORT: &str = "not enabled";

Loading…
Cancel
Save