mod commands;
mod keys;
mod sshcfg;
mod tui;
mod tunnels;
use clap::{Parser, Subcommand};
const AFTER: &str = "Run `essh` with no arguments to open the toolbox (keys, tunnels, mounts, add host).
Any other word is an ssh destination: `essh raspi`, `essh raspi -p 2222`.";
#[derive(Parser)]
#[command(
name = "easyssh",
bin_name = "essh",
version,
about = "make ssh easy — hosts, keys, tunnels, mounts and copies in one tool",
after_help = AFTER
)]
struct Cli {
#[command(subcommand)]
command: Option<Cmd>,
}
#[derive(Subcommand)]
enum Cmd {
#[command(verbatim_doc_comment)]
Ls(commands::ls::Args),
Cp(commands::cp::Args),
#[command(external_subcommand)]
Connect(Vec<String>),
}
fn main() {
let cli = Cli::parse();
match cli.command {
None => {
if let Err(e) = tui::run() {
eprintln!("essh: {e}");
std::process::exit(1);
}
}
Some(Cmd::Ls(args)) => commands::ls::run(args),
Some(Cmd::Cp(args)) => commands::cp::run(args),
Some(Cmd::Connect(args)) => commands::connect::run(args),
}
}