Skip to content

Commit 37a991a

Browse files
committed
update possible_forc_commands fn to find missing plugins
1 parent 8d385d5 commit 37a991a

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

scripts/mdbook-forc-documenter/src/commands.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
use crate::formatter::{format_header_line, format_line};
22
use anyhow::{anyhow, Result};
3-
use std::collections::HashMap;
4-
use std::ffi::OsString;
5-
use std::process;
3+
use std::{collections::HashMap, ffi::OsString, process};
64

75
pub fn possible_forc_commands() -> Vec<String> {
8-
let mut possible_commands = Vec::new();
96
let output = process::Command::new("forc")
107
.arg("--help")
118
.output()
@@ -14,18 +11,28 @@ pub fn possible_forc_commands() -> Vec<String> {
1411
let output_str = String::from_utf8_lossy(&output.stdout);
1512
let lines = output_str.lines();
1613

17-
let mut has_parsed_subcommand_header = false;
14+
let mut possible_commands = Vec::new();
15+
let mut in_commands_section = false;
1816

1917
for line in lines {
20-
if has_parsed_subcommand_header {
21-
let (command, _) = line.trim().split_once(' ').unwrap_or(("", ""));
22-
possible_commands.push(command.to_string());
18+
if line.trim() == "Commands:" {
19+
// Start of commands section
20+
in_commands_section = true;
21+
continue;
2322
}
24-
if line == "SUBCOMMANDS:" {
25-
has_parsed_subcommand_header = true;
23+
24+
if in_commands_section {
25+
if line.trim().is_empty() || line.trim().starts_with("Options:") {
26+
// End of commands section
27+
break;
28+
}
29+
30+
// Extract command name (first word of the line)
31+
if let Some(command) = line.trim().split_whitespace().next() {
32+
possible_commands.push(command.to_string());
33+
}
2634
}
2735
}
28-
2936
possible_commands
3037
}
3138

0 commit comments

Comments
 (0)