parallel flattened queue for recursive --help resolution
Replace recursive depth-first help_resolve with BFS queue + fork-based parallelism (up to num_cores workers). Workers marshal results back via pipes; discovered subcommands are enqueued for the next wave. Also fix usage positional extraction to match "USAGE" without colon (Go/Cobra style), and skip empty-result check to consider positionals.
This commit is contained in:
parent
3cc278b144
commit
d0cc80109e
2 changed files with 102 additions and 38 deletions
|
|
@ -415,18 +415,21 @@ let extract_usage_positionals text =
|
|||
else
|
||||
let t = String.trim lines_arr.(i) in
|
||||
let tlen = String.length t in
|
||||
if tlen >= 6 then
|
||||
let prefix = String.lowercase_ascii (String.sub t 0 6) in
|
||||
if prefix = "usage:" then begin
|
||||
let after = String.sub t 6 (tlen - 6) |> String.trim in
|
||||
if String.length after > 0 then Some after
|
||||
else if i + 1 < len then
|
||||
(* Clap style: USAGE:\n cmd [OPTIONS] PATTERN *)
|
||||
let next = String.trim lines_arr.(i + 1) in
|
||||
if String.length next > 0 then Some next else None
|
||||
else None
|
||||
end else go (i + 1)
|
||||
else go (i + 1)
|
||||
let lc = String.lowercase_ascii t in
|
||||
if tlen >= 6 && String.sub lc 0 6 = "usage:" then begin
|
||||
let after = String.sub t 6 (tlen - 6) |> String.trim in
|
||||
if String.length after > 0 then Some after
|
||||
else if i + 1 < len then
|
||||
(* Clap style: USAGE:\n cmd [OPTIONS] PATTERN *)
|
||||
let next = String.trim lines_arr.(i + 1) in
|
||||
if String.length next > 0 then Some next else None
|
||||
else None
|
||||
end else if lc = "usage" then begin
|
||||
if i + 1 < len then
|
||||
let next = String.trim lines_arr.(i + 1) in
|
||||
if String.length next > 0 then Some next else None
|
||||
else None
|
||||
end else go (i + 1)
|
||||
in
|
||||
go 0
|
||||
in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue