diff --git a/src/command.rs b/src/command.rs index f2d968e..8be8018 100644 --- a/src/command.rs +++ b/src/command.rs @@ -10,98 +10,6 @@ use tmux_interface::TmuxCommand; use crate::error; use crate::util; -pub fn help(pargs: &mut Arguments) { - let topic = pargs.subcommand().unwrap(); - - match topic.as_deref() { - None => { - println!("remux v{}", env!("CARGO_PKG_VERSION")); - println!("Valerie Wolfe "); - println!("A command wrapper for tmux written in Rust.\n"); - - println!("usage: remux []\n"); - - println!("Commands:"); - println!(" help Show help text for remux or a specific command"); - println!(" attach Attach to an existing tmux session"); - println!(" detach Detach clients from a tmux session"); - println!(" has Check if a tmux session exists"); - println!(" list Pretty-print all tmux sessions"); - println!(" new Create a new tmux session"); - - println!("\nUse 'remux help ' to see detailed help text for each command."); - }, - - - Some("a" | "attach") - => { - println!("remux attach"); - println!("Attach to an existing session.\n"); - - println!("usage: remux attach [flags] [window]\n"); - - println!("args:"); - println!(" The session to attach to"); - println!(" [window] Optionally focus a window in the given session\n"); - - println!("flags:"); - println!(" -d, --detach Detach other attached clients from the session"); - println!(" -r, --readonly Attach the session as read-only"); - }, - - Some("d" | "detach") - => { - println!("remux detach"); - println!("Detach all clients from a session.\n"); - - println!("usage: remux detach \n"); - - println!("args:"); - println!(" The session name to detach clients from"); - }, - - Some("has") - => { - println!("remux has"); - println!("Check if the target session exists.\n"); - - println!("usage: remux has [flags] \n"); - - println!("args:"); - println!(" The session to check for\n"); - - println!("flags:"); - println!(" -q, --quiet Display no text; exit code only"); - }, - - Some("l" | "ls" | "list") - => { - println!("remux list"); - println!("Pretty-print all tmux sessions.\n"); - - println!("usage: remux list"); - }, - - Some("n" | "new") - => { - println!("remux new"); - println!("Create a new tmux session.\n"); - - println!("usage: remux new [flags] [command]\n"); - - println!("args:"); - println!(" <title> The title of the new session"); - println!(" [command] The shell command to run\n"); - - println!("flags:"); - println!(" -t, --target <dir> Sets the target directory for the new session."); - }, - - // not found - _ => error::no_help(topic.unwrap()) - } -} - pub fn attach(pargs: &mut Arguments) { util::prevent_nest(); diff --git a/src/help.rs b/src/help.rs new file mode 100644 index 0000000..e53042e --- /dev/null +++ b/src/help.rs @@ -0,0 +1,98 @@ +use std::process::exit; + +use pico_args::Arguments; + +use crate::error; + +pub fn help(pargs: &mut Arguments) { + let topic = pargs.subcommand().unwrap(); + + match topic.as_deref() { + None => { + println!("remux v{}", env!("CARGO_PKG_VERSION")); + println!("Valerie Wolfe <sleeplessval@gmail.com>"); + println!("A command wrapper for tmux written in Rust.\n"); + + println!("usage: remux <command> [<args>]\n"); + + println!("Commands:"); + println!(" help Show help text for remux or a specific command"); + println!(" attach Attach to an existing tmux session"); + println!(" detach Detach clients from a tmux session"); + println!(" has Check if a tmux session exists"); + println!(" list Pretty-print all tmux sessions"); + println!(" new Create a new tmux session"); + + println!("\nUse 'remux help <command>' to see detailed help text for each command."); + }, + + + Some("a" | "attach") + => { + println!("remux attach"); + println!("Attach to an existing session.\n"); + + println!("usage: remux attach [flags] <session> [window]\n"); + + println!("args:"); + println!(" <session> The session to attach to"); + println!(" [window] Optionally focus a window in the given session\n"); + + println!("flags:"); + println!(" -d, --detach Detach other attached clients from the session"); + println!(" -r, --readonly Attach the session as read-only"); + }, + + Some("d" | "detach") + => { + println!("remux detach"); + println!("Detach all clients from a session.\n"); + + println!("usage: remux detach <session>\n"); + + println!("args:"); + println!(" <session> The session name to detach clients from"); + }, + + Some("has") + => { + println!("remux has"); + println!("Check if the target session exists.\n"); + + println!("usage: remux has [flags] <session>\n"); + + println!("args:"); + println!(" <session> The session to check for\n"); + + println!("flags:"); + println!(" -q, --quiet Display no text; exit code only"); + }, + + Some("l" | "ls" | "list") + => { + println!("remux list"); + println!("Pretty-print all tmux sessions.\n"); + + println!("usage: remux list"); + }, + + Some("n" | "new") + => { + println!("remux new"); + println!("Create a new tmux session.\n"); + + println!("usage: remux new [flags] <title> [command]\n"); + + println!("args:"); + println!(" <title> The title of the new session"); + println!(" [command] The shell command to run\n"); + + println!("flags:"); + println!(" -t, --target <dir> Sets the target directory for the new session."); + }, + + // not found + _ => error::no_help(topic.unwrap()) + } +} + diff --git a/src/main.rs b/src/main.rs index 74ed31f..20aa071 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,13 +4,16 @@ use pico_args::Arguments; mod command; mod error; +mod help; mod util; +use help::help; + fn main() { let mut args = Arguments::from_env(); if args.contains(["-h", "--help"]) { - command::help(&mut args); + help(&mut args); return; } @@ -20,7 +23,7 @@ fn main() { match subcommand.as_deref() { Some("h" | "help") - => command::help(&mut args), + => help(&mut args), Some("a" | "attach") => command::attach(&mut args),