use clap::{Parser, Subcommand};
use drake::Drake;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Cli {
#[command(subcommand)]
command: Command,
}
#[derive(Subcommand)]
enum Command {
Deps {
type_name: String,
#[arg(default_value = ".")]
path: String,
#[arg(long = "all")]
all: bool,
},
Print {
#[arg(default_value = ".")]
path: String,
#[arg(short, long = "decl")]
declarations: bool,
#[arg(short, long = "refs")]
references: bool,
#[arg(long)]
full: bool,
},
}
fn main() -> anyhow::Result<()> {
let cli = Cli::parse();
let mut drake = Drake::new();
match &cli.command {
Command::Deps {
path,
type_name,
all,
} => {
drake.scan(path)?;
drake.print_dependencies(type_name, *all)?;
}
Command::Print {
path,
declarations,
references,
full,
} => drake.print(path, *declarations, *references, *full)?,
}
Ok(())
}