use std::path::PathBuf;
use std::process::ExitCode;
use clap::Parser;
use clap::Subcommand;
mod ci;
mod config;
mod list;
mod output;
mod project;
mod scan;
mod tui;
mod watcher;
use ci::CiArgs;
use list::ListArgs;
#[derive(Parser)]
#[command(name = "cargo-port", about = "Inspect Rust project structures")]
struct Cli {
#[arg(default_value = ".")]
path: PathBuf,
#[command(subcommand)]
command: Option<Commands>,
}
#[derive(Subcommand)]
enum Commands {
List(ListArgs),
Ci(CiArgs),
}
fn normalized_args() -> Vec<String> {
let mut args: Vec<String> = std::env::args().collect();
if args.len() > 1 && args[1] == "port" {
args.remove(1);
}
args
}
fn main() -> ExitCode {
let cli = Cli::parse_from(normalized_args());
match cli.command {
Some(Commands::List(args)) => list::run(cli.path, args),
Some(Commands::Ci(args)) => ci::run(cli.path, args),
None => tui::run(cli.path),
}
}