diff --git a/Cargo.toml b/Cargo.toml index bf01359..e89a113 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "remux" -version = "0.1.0" +version = "0.1.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/help.rs b/src/help.rs index e53042e..b567bb4 100644 --- a/src/help.rs +++ b/src/help.rs @@ -3,13 +3,14 @@ use std::process::exit; use pico_args::Arguments; use crate::error; +use crate::VERSION; pub fn help(pargs: &mut Arguments) { let topic = pargs.subcommand().unwrap(); match topic.as_deref() { None => { - println!("remux v{}", env!("CARGO_PKG_VERSION")); + println!("remux v{VERSION}"); println!("Valerie Wolfe "); println!("A command wrapper for tmux written in Rust.\n"); @@ -96,3 +97,7 @@ pub fn help(pargs: &mut Arguments) { } } +pub fn version() { + println!("remux v{VERSION}"); +} + diff --git a/src/main.rs b/src/main.rs index 20aa071..cc2ef7c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,16 +7,24 @@ mod error; mod help; mod util; -use help::help; +use help::{ help, version }; + +static VERSION: &str = env!("CARGO_PKG_VERSION"); fn main() { let mut args = Arguments::from_env(); + if args.contains(["-h", "--help"]) { help(&mut args); return; } + if args.contains(["-v", "--version"]) { + version(); + return; + } + if !stdout().is_terminal() { error::not_terminal(); } let subcommand = args.subcommand().unwrap();