diff options
| author | Reiner Herrmann <reiner@reiner-h.de> | 2019-03-08 20:59:04 +0100 |
|---|---|---|
| committer | Reiner Herrmann <reiner@reiner-h.de> | 2019-03-08 20:59:04 +0100 |
| commit | 048c513204ec3ee2f85c6667590ae644b46f92e0 (patch) | |
| tree | 8980de6e908fd630d58383085647675c2bfb66a6 /src | |
| parent | 7202a395f9397ef22e137037a31d85668ceb1be7 (diff) | |
Display version number in usage text
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 2 | ||||
| -rw-r--r-- | src/tftpc.rs | 3 | ||||
| -rw-r--r-- | src/tftpd.rs | 3 |
3 files changed, 6 insertions, 2 deletions
@@ -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<String>) { if let Some(err) = error { println!("{}\n", err); } - println!("{}", opts.usage(format!("RusTFTP\n\n{} [options] <remote>[:port]", program).as_str())); + let version = rtftp::VERSION.unwrap_or(""); + println!("{}", opts.usage(format!("RusTFTP {}\n\n{} [options] <remote>[:port]", version, program).as_str())); } fn parse_commandline(args: &[String]) -> Result<Configuration, &str> { 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<String>) { 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<Configuration, &str> { |
