From 048c513204ec3ee2f85c6667590ae644b46f92e0 Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Fri, 8 Mar 2019 20:59:04 +0100 Subject: Display version number in usage text --- src/lib.rs | 2 ++ src/tftpc.rs | 3 ++- src/tftpd.rs | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7e0051a..659e2df 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,6 +11,8 @@ use std::net::{SocketAddr, UdpSocket}; use std::path::{Path, PathBuf}; use std::time::Duration; +pub static VERSION: Option<&str> = option_env!("CARGO_PKG_VERSION"); + #[repr(u16)] pub enum Opcodes { RRQ = 0x01, diff --git a/src/tftpc.rs b/src/tftpc.rs index 689d055..adac705 100644 --- a/src/tftpc.rs +++ b/src/tftpc.rs @@ -249,7 +249,8 @@ fn usage(opts: Options, program: String, error: Option) { if let Some(err) = error { println!("{}\n", err); } - println!("{}", opts.usage(format!("RusTFTP\n\n{} [options] [:port]", program).as_str())); + let version = rtftp::VERSION.unwrap_or(""); + println!("{}", opts.usage(format!("RusTFTP {}\n\n{} [options] [:port]", version, program).as_str())); } fn parse_commandline(args: &[String]) -> Result { diff --git a/src/tftpd.rs b/src/tftpd.rs index 48e7a40..c8bd5b5 100644 --- a/src/tftpd.rs +++ b/src/tftpd.rs @@ -282,7 +282,8 @@ fn usage(opts: Options, program: String, error: Option) { if let Some(err) = error { println!("{}\n", err); } - println!("{}", opts.usage(format!("RusTFTP\n\n{} [options]", program).as_str())); + let version = rtftp::VERSION.unwrap_or(""); + println!("{}", opts.usage(format!("RusTFTP {}\n\n{} [options]", version, program).as_str())); } fn parse_commandline(args: &[String]) -> Result { -- cgit v1.2.3