Skip to main content

gor/cmd/
mod.rs

1//! Command implementations for `gor`.
2//!
3//! Each subcommand lives in its own module. The [`dispatch`] function
4//! routes parsed CLI arguments to the appropriate command handler.
5
6pub mod alias;
7pub mod api;
8pub mod attestation;
9pub mod auth;
10pub mod browse;
11pub mod cache;
12pub mod classroom;
13pub mod codespace;
14pub mod completion;
15pub mod config;
16pub mod copilot;
17pub mod extension;
18pub mod gist;
19pub mod issue;
20pub mod keys;
21pub mod label;
22pub mod org;
23pub mod pr;
24pub mod project;
25pub mod release;
26pub mod repo;
27pub mod ruleset;
28pub mod run;
29pub mod search;
30pub mod secret;
31pub mod util;
32pub mod variable;
33pub mod workflow;
34
35use crate::cli::{Args, Command};
36
37/// Dispatch a parsed CLI command to its handler.
38///
39/// # Errors
40///
41/// Returns an error if the command execution fails.
42#[allow(clippy::print_stdout)]
43pub fn dispatch(args: Args) -> anyhow::Result<()> {
44    match args.command {
45        Command::Api(cmd) => api::run(&cmd, args.hostname.as_deref()),
46        Command::Auth(cmd) => auth::run(cmd),
47        Command::Repo(cmd) => repo::run(cmd),
48        Command::Pr(cmd) => pr::run(cmd),
49        Command::Issue(cmd) => issue::run(cmd),
50        Command::Config(cmd) => config::run(cmd, args.hostname.as_deref()),
51        Command::Label(cmd) => label::run(cmd),
52        Command::Release(cmd) => release::run(cmd),
53        Command::Browse(cmd) => browse::run(cmd, args.hostname.as_deref()),
54        Command::Gist(cmd) => gist::run(cmd),
55        Command::Search(cmd) => search::run(cmd),
56        Command::Workflow(cmd) => workflow::run(cmd),
57        Command::Alias(cmd) => alias::run(cmd),
58        Command::Org(cmd) => org::run(cmd),
59        Command::SshKey(cmd) => keys::run_ssh(cmd),
60        Command::GpgKey(cmd) => keys::run_gpg(cmd),
61        Command::Secret(cmd) => secret::run(cmd),
62        Command::Variable(cmd) => variable::run(cmd),
63        Command::Run(cmd) => run::run(cmd),
64        Command::Cache(cmd) => cache::run(cmd),
65        Command::Ruleset(cmd) => ruleset::run(cmd),
66        Command::Extension(cmd) => extension::run(cmd),
67        Command::Codespace(cmd) => codespace::run(cmd),
68        Command::Project(cmd) => project::run(cmd),
69        Command::Attestation(cmd) => attestation::run(cmd),
70        Command::Classroom(cmd) => classroom::run(cmd),
71        Command::Copilot(cmd) => copilot::run(cmd),
72        Command::Completion { shell } => completion::run(&shell),
73    }
74}