#[cfg(not(target_os = "emscripten"))]
mod cmd_auth;
mod cmd_cache;
mod cmd_derive;
mod cmd_export;
mod cmd_haiku;
mod cmd_import;
mod cmd_incept;
mod cmd_list;
mod cmd_merge;
mod cmd_p;
#[cfg(not(target_os = "emscripten"))]
mod cmd_pathbase;
mod cmd_project;
mod cmd_query;
mod cmd_render;
#[cfg(not(target_os = "emscripten"))]
pub mod cmd_resume;
#[cfg(not(target_os = "emscripten"))]
mod cmd_share;
#[cfg(not(target_os = "emscripten"))]
mod cmd_show;
mod cmd_track;
mod cmd_validate;
mod config;
#[cfg(not(target_os = "emscripten"))]
mod fuzzy;
mod io;
mod schema;
#[cfg(all(not(target_os = "emscripten"), feature = "embedded-picker"))]
mod skim_picker;
mod term;
use anyhow::Result;
use clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(name = "path", version)]
#[command(about = "Derive, query, and visualize Toolpath provenance documents")]
struct Cli {
#[command(subcommand)]
command: Commands,
#[arg(long, global = true)]
pretty: bool,
#[cfg(not(target_os = "emscripten"))]
#[arg(long, global = true, value_enum, default_value_t = fuzzy::Picker::Auto)]
picker: fuzzy::Picker,
}
#[derive(Subcommand, Debug)]
enum Commands {
#[cfg(not(target_os = "emscripten"))]
Show {
#[command(subcommand)]
source: cmd_show::ShowSource,
#[arg(long)]
ansi: bool,
},
#[cfg(not(target_os = "emscripten"))]
Share {
#[command(flatten)]
args: cmd_share::ShareArgs,
},
#[cfg(not(target_os = "emscripten"))]
Resume {
#[command(flatten)]
args: cmd_resume::ResumeArgs,
},
Query {
#[command(subcommand)]
op: cmd_query::QueryOp,
},
#[cfg(not(target_os = "emscripten"))]
Auth {
#[command(subcommand)]
op: cmd_auth::AuthOp,
},
P {
#[command(subcommand)]
command: cmd_p::PCommand,
},
Haiku,
}
pub fn run() -> Result<()> {
let cli = Cli::parse();
#[cfg(not(target_os = "emscripten"))]
fuzzy::set_picker_override(cli.picker);
match cli.command {
Commands::Haiku => {
cmd_haiku::run();
Ok(())
}
#[cfg(not(target_os = "emscripten"))]
Commands::Show { source, ansi } => cmd_show::run(source, ansi),
#[cfg(not(target_os = "emscripten"))]
Commands::Share { args } => cmd_share::run(args),
#[cfg(not(target_os = "emscripten"))]
Commands::Resume { args } => cmd_resume::run(args),
Commands::Query { op } => cmd_query::run(op, cli.pretty),
#[cfg(not(target_os = "emscripten"))]
Commands::Auth { op } => cmd_auth::run(op),
Commands::P { command } => cmd_p::run(command, cli.pretty),
}
}