Skip to content

Commit fd18fe7

Browse files
checkpoint, moved list_crate_items moved to tools
1 parent ae1fc42 commit fd18fe7

File tree

1 file changed

+43
-4
lines changed

1 file changed

+43
-4
lines changed

src/bin/cratedocs.rs

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ enum Commands {
4040
},
4141
/// Test tools directly from the CLI
4242
Test {
43-
/// The tool to test (lookup_crate, search_crates, lookup_item)
43+
/// The tool to test (lookup_crate, search_crates, lookup_item, list_crate_items)
4444
#[arg(long, default_value = "lookup_crate")]
4545
tool: String,
4646

47-
/// Crate name for lookup_crate and lookup_item
47+
/// Crate name for lookup_crate, lookup_item, and list_crate_items
4848
#[arg(long)]
4949
crate_name: Option<String>,
5050

@@ -64,18 +64,30 @@ enum Commands {
6464
#[arg(long)]
6565
limit: Option<u32>,
6666

67+
/// Filter by item type for list_crate_items (e.g., struct, enum, trait)
68+
#[arg(long)]
69+
item_type: Option<String>,
70+
71+
/// Filter by visibility for list_crate_items (e.g., pub, private)
72+
#[arg(long)]
73+
visibility: Option<String>,
74+
75+
/// Filter by module path for list_crate_items (e.g., serde::de)
76+
#[arg(long)]
77+
module: Option<String>,
78+
6779
/// Output format (markdown, text, json)
6880
#[arg(long, default_value = "markdown")]
6981
format: Option<String>,
7082

7183
/// Output file path (if not specified, results will be printed to stdout)
7284
#[arg(long)]
7385
output: Option<String>,
74-
86+
7587
/// Summarize output by stripping LICENSE and VERSION sections (TL;DR mode)
7688
#[arg(long)]
7789
tldr: bool,
78-
90+
7991
/// Maximum number of tokens for output (token-aware truncation)
8092
#[arg(long)]
8193
max_tokens: Option<usize>,
@@ -100,6 +112,9 @@ async fn main() -> Result<()> {
100112
query,
101113
version,
102114
limit,
115+
item_type,
116+
visibility,
117+
module,
103118
format,
104119
output,
105120
tldr,
@@ -112,6 +127,9 @@ async fn main() -> Result<()> {
112127
query,
113128
version,
114129
limit,
130+
item_type,
131+
visibility,
132+
module,
115133
format,
116134
output,
117135
tldr,
@@ -212,6 +230,9 @@ struct TestToolConfig {
212230
query: Option<String>,
213231
version: Option<String>,
214232
limit: Option<u32>,
233+
item_type: Option<String>,
234+
visibility: Option<String>,
235+
module: Option<String>,
215236
format: Option<String>,
216237
output: Option<String>,
217238
tldr: bool,
@@ -233,6 +254,9 @@ async fn run_test_tool(config: TestToolConfig) -> Result<()> {
233254
tldr,
234255
max_tokens,
235256
debug,
257+
item_type,
258+
visibility,
259+
module,
236260
} = config;
237261
// Print help information if the tool is "help"
238262
if tool == "help" {
@@ -308,6 +332,21 @@ async fn run_test_tool(config: TestToolConfig) -> Result<()> {
308332
"limit": limit,
309333
})
310334
},
335+
"list_crate_items" => {
336+
let crate_name = crate_name.ok_or_else(||
337+
anyhow::anyhow!("--crate-name is required for list_crate_items tool"))?;
338+
let version = version.ok_or_else(||
339+
anyhow::anyhow!("--version is required for list_crate_items tool"))?;
340+
341+
let arguments = json!({
342+
"crate_name": crate_name,
343+
"version": version,
344+
"item_type": item_type,
345+
"visibility": visibility,
346+
"module": module,
347+
});
348+
arguments
349+
},
311350
_ => return Err(anyhow::anyhow!("Unknown tool: {}", tool)),
312351
};
313352

0 commit comments

Comments
 (0)