torvyn_cli/commands/
mod.rs1pub mod bench;
6pub mod check;
7pub mod doctor;
8pub mod init;
9pub mod inspect;
10pub mod link;
11pub mod pack;
12pub mod publish;
13pub mod run;
14pub mod trace;
15
16use crate::cli::{Command, GlobalOpts};
17use crate::errors::CliError;
18use crate::output::OutputContext;
19
20pub async fn execute_command(
24 command: &Command,
25 _global: &GlobalOpts,
26 ctx: &OutputContext,
27) -> Result<(), CliError> {
28 match command {
29 Command::Init(args) => {
30 let result = init::execute(args, ctx).await?;
31 ctx.render(&result);
32 }
33 Command::Check(args) => {
34 let result = check::execute(args, ctx).await?;
35 ctx.render(&result);
36 }
37 Command::Link(args) => {
38 let result = link::execute(args, ctx).await?;
39 ctx.render(&result);
40 }
41 Command::Run(args) => {
42 let result = run::execute(args, ctx).await?;
43 ctx.render(&result);
44 }
45 Command::Trace(args) => {
46 let result = trace::execute(args, ctx).await?;
47 ctx.render(&result);
48 }
49 Command::Bench(args) => {
50 let result = bench::execute(args, ctx).await?;
51 ctx.render(&result);
52 }
53 Command::Pack(args) => {
54 let result = pack::execute(args, ctx).await?;
55 ctx.render(&result);
56 }
57 Command::Publish(args) => {
58 let result = publish::execute(args, ctx).await?;
59 ctx.render(&result);
60 }
61 Command::Inspect(args) => {
62 let result = inspect::execute(args, ctx).await?;
63 ctx.render(&result);
64 }
65 Command::Doctor(args) => {
66 let result = doctor::execute(args, ctx).await?;
67 ctx.render(&result);
68 }
69 Command::Completions(args) => {
70 generate_completions(args);
71 }
72 }
73 Ok(())
74}
75
76fn generate_completions(args: &crate::cli::CompletionsArgs) {
78 use clap::CommandFactory;
79 use clap_complete::{generate, Shell};
80
81 let mut cmd = crate::cli::Cli::command();
82 let shell = match args.shell {
83 crate::cli::ShellKind::Bash => Shell::Bash,
84 crate::cli::ShellKind::Zsh => Shell::Zsh,
85 crate::cli::ShellKind::Fish => Shell::Fish,
86 crate::cli::ShellKind::PowerShell => Shell::PowerShell,
87 };
88 generate(shell, &mut cmd, "torvyn", &mut std::io::stdout());
89}