use anyhow::Result;
use clap::{Parser, Subcommand};
use whoseportisitanyway::cli;
use whoseportisitanyway::config::Config;
use whoseportisitanyway::tui;
#[derive(Parser)]
#[command(
name = "whoseportisitanyway",
version = env!("WHOSEPORT_VERSION"),
about = "Which ports are in use, who owns them, and is it your dev server or something blocking it?"
)]
struct Cli {
#[command(subcommand)]
command: Option<Command>,
}
#[derive(Subcommand)]
enum Command {
Snapshot {
#[arg(long)]
json: bool,
},
Why {
port: u16,
},
List {
#[arg(long)]
plain: bool,
},
}
fn main() -> Result<()> {
let args = Cli::parse();
let config = Config::load()?;
match args.command {
None => tui::run(&config),
Some(Command::Snapshot { json }) => cli::snapshot::run(&config, json),
Some(Command::Why { port }) => cli::why::run(&config, port),
Some(Command::List { plain }) => cli::list::run(&config, plain),
}
}