mod commands;
mod keys;
mod mounts;
mod sshcfg;
mod tui;
mod tunnels;
use clap::{Parser, Subcommand};
const AFTER: &str = "\
Two more ways to run it (not subcommands):
essh open the toolbox (TUI): hosts, keys, tunnels, mounts
essh <host> [args] connect (any unknown word is an ssh destination, e.g. `essh raspi -p 2222`)
The toolbox is where keys, tunnels, mounts, and adding/editing hosts live.
Run `essh <command> --help` for a command's details.";
#[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),
#[command(verbatim_doc_comment)]
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),
}
}