1pub mod artifact;
2mod cache;
3#[cfg(not(target_os = "emscripten"))]
4mod cmd_auth;
5mod cmd_cache;
6mod cmd_derive;
7mod cmd_export;
8mod cmd_haiku;
9mod cmd_import;
10mod cmd_incept;
11mod cmd_kind;
12mod cmd_list;
13mod cmd_merge;
14mod cmd_p;
15mod cmd_p_query;
16#[cfg(not(target_os = "emscripten"))]
17mod cmd_pathbase;
18mod cmd_project;
19mod cmd_query;
20mod cmd_render;
21#[cfg(not(target_os = "emscripten"))]
22pub mod cmd_resume;
23#[cfg(not(target_os = "emscripten"))]
24mod cmd_share;
25#[cfg(not(target_os = "emscripten"))]
26mod cmd_show;
27mod cmd_track;
28mod cmd_validate;
29mod config;
30mod derive;
31#[cfg(not(target_os = "emscripten"))]
32mod fuzzy;
33#[cfg(not(target_os = "emscripten"))]
34pub mod harness;
35mod io;
36mod kinds;
37mod query;
38mod schema;
39#[cfg(all(not(target_os = "emscripten"), feature = "embedded-picker"))]
40mod skim_picker;
41mod sync;
42mod term;
43
44use anyhow::Result;
45use clap::{Parser, Subcommand};
46
47#[derive(Parser, Debug)]
48#[command(name = "path", version)]
49#[command(about = "Derive, query, and visualize Toolpath provenance documents")]
50struct Cli {
51 #[command(subcommand)]
52 command: Commands,
53
54 #[arg(long, global = true)]
56 pretty: bool,
57
58 #[cfg(not(target_os = "emscripten"))]
65 #[arg(long, global = true, value_enum, default_value_t = fuzzy::Picker::Auto)]
66 picker: fuzzy::Picker,
67}
68
69#[derive(Subcommand, Debug)]
70enum Commands {
71 #[cfg(not(target_os = "emscripten"))]
73 Show {
74 #[command(subcommand)]
75 source: cmd_show::ShowSource,
76 #[arg(long)]
80 ansi: bool,
81 },
82 #[cfg(not(target_os = "emscripten"))]
84 Share {
85 #[command(flatten)]
86 args: cmd_share::ShareArgs,
87 },
88 #[cfg(not(target_os = "emscripten"))]
91 Resume {
92 #[command(flatten)]
93 args: cmd_resume::ResumeArgs,
94 },
95 Query {
98 #[command(flatten)]
99 args: cmd_query::QueryArgs,
100 },
101 Kind {
104 #[command(flatten)]
105 args: cmd_kind::KindArgs,
106 },
107 #[cfg(not(target_os = "emscripten"))]
109 Auth {
110 #[command(subcommand)]
111 op: cmd_auth::AuthOp,
112 },
113 P {
117 #[command(subcommand)]
118 command: cmd_p::PCommand,
119 },
120 Haiku,
122}
123
124pub fn run() -> Result<()> {
125 let cli = Cli::parse();
126
127 #[cfg(not(target_os = "emscripten"))]
128 fuzzy::set_picker_override(cli.picker);
129
130 match cli.command {
131 Commands::Haiku => {
132 cmd_haiku::run();
133 Ok(())
134 }
135 #[cfg(not(target_os = "emscripten"))]
136 Commands::Show { source, ansi } => cmd_show::run(source, ansi),
137 #[cfg(not(target_os = "emscripten"))]
138 Commands::Share { args } => cmd_share::run(args),
139 #[cfg(not(target_os = "emscripten"))]
140 Commands::Resume { args } => cmd_resume::run(args),
141 Commands::Query { args } => cmd_query::run(args, cli.pretty),
142 Commands::Kind { args } => cmd_kind::run(args),
143 #[cfg(not(target_os = "emscripten"))]
144 Commands::Auth { op } => cmd_auth::run(op),
145 Commands::P { command } => cmd_p::run(command, cli.pretty),
146 }
147}