Skip to main content

crates_docs/cli/
commands.rs

1//! CLI commands definition
2
3use clap::Subcommand;
4use std::path::PathBuf;
5
6/// Available CLI commands
7#[derive(Subcommand)]
8pub enum Commands {
9    /// Start the server
10    Serve {
11        /// Transport mode [stdio, http, sse, hybrid]
12        #[arg(short, long)]
13        mode: Option<String>,
14
15        /// Listen host
16        #[arg(long)]
17        host: Option<String>,
18
19        /// Listen port
20        #[arg(short, long)]
21        port: Option<u16>,
22
23        /// Enable OAuth authentication
24        #[arg(long)]
25        enable_oauth: Option<bool>,
26
27        /// OAuth client ID
28        #[arg(long)]
29        oauth_client_id: Option<String>,
30
31        /// OAuth client secret
32        #[arg(long)]
33        oauth_client_secret: Option<String>,
34
35        /// OAuth redirect URI
36        #[arg(long)]
37        oauth_redirect_uri: Option<String>,
38
39        /// Enable API Key authentication
40        #[arg(long)]
41        enable_api_key: Option<bool>,
42
43        /// API Key(s) for authentication (comma-separated for multiple keys)
44        #[arg(long)]
45        api_keys: Option<String>,
46
47        /// API Key header name (default: X-API-Key)
48        #[arg(long)]
49        api_key_header: Option<String>,
50
51        /// Allow API Key in query parameter
52        #[arg(long)]
53        api_key_query_param: Option<bool>,
54    },
55
56    /// Generate API key for hashed storage
57    GenerateApiKey {
58        /// Key prefix used when generating the API key
59        #[arg(long, default_value = "sk")]
60        prefix: String,
61    },
62
63    /// List API keys from configuration file
64    ListApiKeys {
65        /// Configuration file path
66        #[arg(short, long, default_value = "config.toml")]
67        config: PathBuf,
68    },
69
70    /// Revoke an API key from configuration file
71    RevokeApiKey {
72        /// Configuration file path
73        #[arg(short, long, default_value = "config.toml")]
74        config: PathBuf,
75
76        /// Key hash or key ID to revoke
77        #[arg(short, long)]
78        key: String,
79    },
80
81    /// Generate configuration file
82    Config {
83        /// Output file path
84        #[arg(short, long, default_value = "config.toml")]
85        output: PathBuf,
86
87        /// Overwrite existing file
88        #[arg(short, long)]
89        force: bool,
90    },
91
92    /// Test tool
93    Test {
94        /// Tool to test `lookup_crate`, `search_crates`, `lookup_item`, `health_check`
95        #[arg(short, long, default_value = "lookup_crate")]
96        tool: String,
97
98        /// Crate name (for `lookup_crate` and `lookup_item`)
99        #[arg(long)]
100        crate_name: Option<String>,
101
102        /// Item path (for `lookup_item`)
103        #[arg(long)]
104        item_path: Option<String>,
105
106        /// Search query (for `search_crates`)
107        #[arg(long)]
108        query: Option<String>,
109
110        /// Search sort order (for `search_crates`): `relevance`, `downloads`, `recent-downloads`, `recent-updates`, `new`
111        #[arg(long)]
112        sort: Option<String>,
113
114        /// Version number (optional)
115        #[arg(long)]
116        version: Option<String>,
117
118        /// Result limit (for `search_crates`)
119        #[arg(long, default_value = "10")]
120        limit: u32,
121
122        /// Output format: `json`, `markdown`, `text`
123        #[arg(long, default_value = "markdown")]
124        format: String,
125    },
126
127    /// Check server health status
128    Health {
129        /// Check type: `all`, `external`, `internal`, `docs_rs`, `crates_io`
130        #[arg(short = 't', long, default_value = "all")]
131        check_type: String,
132
133        /// Verbose output
134        #[arg(short, long)]
135        verbose: bool,
136    },
137
138    /// Display version information
139    Version,
140}