diff --git a/docs/book/spell-check-custom-words.txt b/docs/book/spell-check-custom-words.txt index 1fc58dea387..6e18232eaf0 100644 --- a/docs/book/spell-check-custom-words.txt +++ b/docs/book/spell-check-custom-words.txt @@ -4,6 +4,7 @@ ASM IDE IDEs LSP +lsp namespace ALU APIs @@ -216,4 +217,14 @@ underflows Codec bool str -multisig \ No newline at end of file +multisig +addr +addr2line +contract-id +init +parse-bytecode +predicate-root +forc-client +crypto +doc +fmt \ No newline at end of file diff --git a/docs/book/src/SUMMARY.md b/docs/book/src/SUMMARY.md index b6d2a2f97cd..262437ea2cc 100644 --- a/docs/book/src/SUMMARY.md +++ b/docs/book/src/SUMMARY.md @@ -80,28 +80,28 @@ - [Workspaces](./forc/workspaces.md) - [Dependencies](./forc/dependencies.md) - [Commands](./forc/commands/index.md) - - [`forc addr2line`](./forc/commands/forc_addr2line.md) - - [`forc build`](./forc/commands/forc_build.md) - - [`forc check`](./forc/commands/forc_check.md) - - [`forc clean`](./forc/commands/forc_clean.md) - - [`forc completions`](./forc/commands/forc_completions.md) - - [`forc contract-id`](./forc/commands/forc_contract-id.md) - - [`forc init`](./forc/commands/forc_init.md) - - [`forc new`](./forc/commands/forc_new.md) - - [`forc parse-bytecode`](./forc/commands/forc_parse-bytecode.md) - - [`forc plugins`](./forc/commands/forc_plugins.md) - - [`forc predicate-root`](./forc/commands/forc_predicate-root.md) - - [`forc test`](./forc/commands/forc_test.md) - - [`forc update`](./forc/commands/forc_update.md) - - [`forc template`](./forc/commands/forc_template.md) + - [forc addr2line](./forc/commands/forc_addr2line.md) + - [forc build](./forc/commands/forc_build.md) + - [forc check](./forc/commands/forc_check.md) + - [forc clean](./forc/commands/forc_clean.md) + - [forc completions](./forc/commands/forc_completions.md) + - [forc contract-id](./forc/commands/forc_contract-id.md) + - [forc init](./forc/commands/forc_init.md) + - [forc new](./forc/commands/forc_new.md) + - [forc parse-bytecode](./forc/commands/forc_parse-bytecode.md) + - [forc plugins](./forc/commands/forc_plugins.md) + - [forc predicate-root](./forc/commands/forc_predicate-root.md) + - [forc test](./forc/commands/forc_test.md) + - [forc update](./forc/commands/forc_update.md) + - [forc template](./forc/commands/forc_template.md) - [Plugins](./forc/plugins/index.md) - - [`forc client`](./forc/plugins/forc_client/index.md) - - [`forc deploy`](./forc/plugins/forc_client/forc_deploy.md) - - [`forc run`](./forc/plugins/forc_client/forc_run.md) - - [`forc submit`](./forc/plugins/forc_client/forc_submit.md) - - [`forc crypto`](./forc/plugins/forc_crypto.md) - - [`forc debug`](./forc/plugins/forc_debug.md) - - [`forc doc`](./forc/plugins/forc_doc.md) - - [`forc explore`](./forc/plugins/forc_explore.md) - - [`forc fmt`](./forc/plugins/forc_fmt.md) - - [`forc lsp`](./forc/plugins/forc_lsp.md) + - [forc client](./forc/plugins/forc_client/index.md) + - [forc deploy](./forc/plugins/forc_client/forc_deploy.md) + - [forc run](./forc/plugins/forc_client/forc_run.md) + - [forc submit](./forc/plugins/forc_client/forc_submit.md) + - [forc crypto](./forc/plugins/forc_crypto.md) + - [forc debug](./forc/plugins/forc_debug.md) + - [forc doc](./forc/plugins/forc_doc.md) + - [forc explore](./forc/plugins/forc_explore.md) + - [forc fmt](./forc/plugins/forc_fmt.md) + - [forc lsp](./forc/plugins/forc_lsp.md) diff --git a/docs/book/src/forc/commands/forc_addr2line.md b/docs/book/src/forc/commands/forc_addr2line.md index cd1835e1c49..9da1be10b3f 100644 --- a/docs/book/src/forc/commands/forc_addr2line.md +++ b/docs/book/src/forc/commands/forc_addr2line.md @@ -1 +1 @@ -# `forc addr2line` +# forc addr2line diff --git a/docs/book/src/forc/commands/forc_build.md b/docs/book/src/forc/commands/forc_build.md index 950396b5f28..f7285039bd7 100644 --- a/docs/book/src/forc/commands/forc_build.md +++ b/docs/book/src/forc/commands/forc_build.md @@ -1 +1 @@ -# `forc build` +# forc build diff --git a/docs/book/src/forc/commands/forc_check.md b/docs/book/src/forc/commands/forc_check.md index 88bd1757b61..49f24c6bc70 100644 --- a/docs/book/src/forc/commands/forc_check.md +++ b/docs/book/src/forc/commands/forc_check.md @@ -1 +1 @@ -# `forc check` +# forc check diff --git a/docs/book/src/forc/commands/forc_clean.md b/docs/book/src/forc/commands/forc_clean.md index 5ce65cb93c3..bbe1d3db337 100644 --- a/docs/book/src/forc/commands/forc_clean.md +++ b/docs/book/src/forc/commands/forc_clean.md @@ -1 +1 @@ -# `forc clean` +# forc clean diff --git a/docs/book/src/forc/commands/forc_completions.md b/docs/book/src/forc/commands/forc_completions.md index 309573d4870..91ae73c0015 100644 --- a/docs/book/src/forc/commands/forc_completions.md +++ b/docs/book/src/forc/commands/forc_completions.md @@ -1 +1 @@ -# `forc completions` +# forc completions diff --git a/docs/book/src/forc/commands/forc_contract-id.md b/docs/book/src/forc/commands/forc_contract-id.md index 81c0f140465..f6c47b041e2 100644 --- a/docs/book/src/forc/commands/forc_contract-id.md +++ b/docs/book/src/forc/commands/forc_contract-id.md @@ -1 +1 @@ -# `forc contract-id` +# forc contract-id diff --git a/docs/book/src/forc/commands/forc_init.md b/docs/book/src/forc/commands/forc_init.md index 0a5ba539d84..9931411557d 100644 --- a/docs/book/src/forc/commands/forc_init.md +++ b/docs/book/src/forc/commands/forc_init.md @@ -1 +1 @@ -# `forc init` +# forc init diff --git a/docs/book/src/forc/commands/forc_new.md b/docs/book/src/forc/commands/forc_new.md index 58fd660c119..0e6e939318c 100644 --- a/docs/book/src/forc/commands/forc_new.md +++ b/docs/book/src/forc/commands/forc_new.md @@ -1 +1 @@ -# `forc new` +# forc new diff --git a/docs/book/src/forc/commands/forc_parse-bytecode.md b/docs/book/src/forc/commands/forc_parse-bytecode.md index 80c67edb461..79d718cc9f7 100644 --- a/docs/book/src/forc/commands/forc_parse-bytecode.md +++ b/docs/book/src/forc/commands/forc_parse-bytecode.md @@ -1 +1 @@ -# `forc parse-bytecode` +# forc parse-bytecode diff --git a/docs/book/src/forc/commands/forc_plugins.md b/docs/book/src/forc/commands/forc_plugins.md index bc0e7aa6c00..a6cfa94c56e 100644 --- a/docs/book/src/forc/commands/forc_plugins.md +++ b/docs/book/src/forc/commands/forc_plugins.md @@ -1 +1 @@ -# `forc plugins` +# forc plugins diff --git a/docs/book/src/forc/commands/forc_predicate-root.md b/docs/book/src/forc/commands/forc_predicate-root.md index 9ed1d7ca56d..863450ebb50 100644 --- a/docs/book/src/forc/commands/forc_predicate-root.md +++ b/docs/book/src/forc/commands/forc_predicate-root.md @@ -1 +1 @@ -# `forc predicate-root` +# forc predicate-root diff --git a/docs/book/src/forc/commands/forc_template.md b/docs/book/src/forc/commands/forc_template.md index 4bc677ff08c..a6cd711e7aa 100644 --- a/docs/book/src/forc/commands/forc_template.md +++ b/docs/book/src/forc/commands/forc_template.md @@ -1 +1 @@ -# `forc template` +# forc template diff --git a/docs/book/src/forc/commands/forc_test.md b/docs/book/src/forc/commands/forc_test.md index 7c4ce2723b7..85254c0002e 100644 --- a/docs/book/src/forc/commands/forc_test.md +++ b/docs/book/src/forc/commands/forc_test.md @@ -1 +1 @@ -# `forc test` +# forc test diff --git a/docs/book/src/forc/commands/forc_update.md b/docs/book/src/forc/commands/forc_update.md index 6805c316eed..0dcb013a3d0 100644 --- a/docs/book/src/forc/commands/forc_update.md +++ b/docs/book/src/forc/commands/forc_update.md @@ -1 +1 @@ -# `forc update` +# forc update diff --git a/docs/book/src/forc/plugins/forc_client/forc_deploy.md b/docs/book/src/forc/plugins/forc_client/forc_deploy.md index 96a3b57a5a5..5fd00d93425 100644 --- a/docs/book/src/forc/plugins/forc_client/forc_deploy.md +++ b/docs/book/src/forc/plugins/forc_client/forc_deploy.md @@ -1 +1 @@ -# `forc deploy` +# forc deploy diff --git a/docs/book/src/forc/plugins/forc_client/forc_run.md b/docs/book/src/forc/plugins/forc_client/forc_run.md index 008a92b9593..7d6f88c8db5 100644 --- a/docs/book/src/forc/plugins/forc_client/forc_run.md +++ b/docs/book/src/forc/plugins/forc_client/forc_run.md @@ -1 +1 @@ -# `forc run` +# forc run diff --git a/docs/book/src/forc/plugins/forc_client/forc_submit.md b/docs/book/src/forc/plugins/forc_client/forc_submit.md index 54e1e5f6c5e..ad314de43e7 100644 --- a/docs/book/src/forc/plugins/forc_client/forc_submit.md +++ b/docs/book/src/forc/plugins/forc_client/forc_submit.md @@ -1 +1 @@ -# `forc submit` +# forc submit diff --git a/docs/book/src/forc/plugins/forc_client/index.md b/docs/book/src/forc/plugins/forc_client/index.md index 4127c9956de..23c668b18d4 100644 --- a/docs/book/src/forc/plugins/forc_client/index.md +++ b/docs/book/src/forc/plugins/forc_client/index.md @@ -1,4 +1,4 @@ -# `forc-client` +# forc-client The forc plugin for interacting with a Fuel node. diff --git a/docs/book/src/forc/plugins/forc_crypto.md b/docs/book/src/forc/plugins/forc_crypto.md index c0789970b64..7c5aa994161 100644 --- a/docs/book/src/forc/plugins/forc_crypto.md +++ b/docs/book/src/forc/plugins/forc_crypto.md @@ -1 +1 @@ -# `forc crypto` +# forc crypto diff --git a/docs/book/src/forc/plugins/forc_doc.md b/docs/book/src/forc/plugins/forc_doc.md index e554a752e6d..2f664873b33 100644 --- a/docs/book/src/forc/plugins/forc_doc.md +++ b/docs/book/src/forc/plugins/forc_doc.md @@ -1 +1 @@ -# `forc doc` +# forc doc diff --git a/docs/book/src/forc/plugins/forc_explore.md b/docs/book/src/forc/plugins/forc_explore.md index b86cb623cdf..c8d4ca5ed5b 100644 --- a/docs/book/src/forc/plugins/forc_explore.md +++ b/docs/book/src/forc/plugins/forc_explore.md @@ -1 +1 @@ -# `forc explore` +# forc explore diff --git a/docs/book/src/forc/plugins/forc_fmt.md b/docs/book/src/forc/plugins/forc_fmt.md index 667a7c1b635..f49f6b7877b 100644 --- a/docs/book/src/forc/plugins/forc_fmt.md +++ b/docs/book/src/forc/plugins/forc_fmt.md @@ -1 +1 @@ -# `forc fmt` +# forc fmt diff --git a/docs/book/src/forc/plugins/forc_lsp.md b/docs/book/src/forc/plugins/forc_lsp.md index b5a93f24f24..624d69001f7 100644 --- a/docs/book/src/forc/plugins/forc_lsp.md +++ b/docs/book/src/forc/plugins/forc_lsp.md @@ -1 +1 @@ -# `forc lsp` +# forc lsp diff --git a/scripts/mdbook-forc-documenter/src/bin/mdbook-forc-documenter.rs b/scripts/mdbook-forc-documenter/src/bin/mdbook-forc-documenter.rs index b273e9550db..1de59586abf 100644 --- a/scripts/mdbook-forc-documenter/src/bin/mdbook-forc-documenter.rs +++ b/scripts/mdbook-forc-documenter/src/bin/mdbook-forc-documenter.rs @@ -1,18 +1,21 @@ use clap::{Arg, ArgMatches, Command}; use mdbook::errors::Error; use mdbook::preprocess::{CmdPreprocessor, Preprocessor}; +use mdbook_forc_documenter::ForcDocumenter; use semver::{Version, VersionReq}; use std::io; use std::process; -use mdbook_forc_documenter::ForcDocumenter; - pub fn make_app() -> Command { Command::new("forc-documenter") .about("A mdbook preprocessor which documents Forc commands") .subcommand( Command::new("supports") - .arg(Arg::new("renderer").required(true)) + .arg( + Arg::new("renderer") + .required(true) + .value_parser(clap::value_parser!(String)), + ) .about("Check whether a renderer is supported by this preprocessor"), ) } @@ -53,7 +56,7 @@ fn handle_preprocessing(pre: &dyn Preprocessor) -> Result<(), Error> { } fn handle_supports(pre: &dyn Preprocessor, sub_args: &ArgMatches) -> ! { - let renderer: &Option<&str> = sub_args.get_one("renderer").expect("Required argument"); + let renderer = sub_args.get_one::("renderer").map(String::as_str); let supported = renderer.map(|r| pre.supports_renderer(r)).unwrap_or(false); // Signal whether the renderer is supported by exiting with 1 or 0. diff --git a/scripts/mdbook-forc-documenter/src/commands.rs b/scripts/mdbook-forc-documenter/src/commands.rs index afbda6ae985..4f1723fc9d8 100644 --- a/scripts/mdbook-forc-documenter/src/commands.rs +++ b/scripts/mdbook-forc-documenter/src/commands.rs @@ -1,11 +1,8 @@ use crate::formatter::{format_header_line, format_line}; use anyhow::{anyhow, Result}; -use std::collections::HashMap; -use std::ffi::OsString; -use std::process; +use std::{collections::HashMap, ffi::OsString, process}; pub fn possible_forc_commands() -> Vec { - let mut possible_commands = Vec::new(); let output = process::Command::new("forc") .arg("--help") .output() @@ -14,18 +11,27 @@ pub fn possible_forc_commands() -> Vec { let output_str = String::from_utf8_lossy(&output.stdout); let lines = output_str.lines(); - let mut has_parsed_subcommand_header = false; + let mut possible_commands = Vec::new(); + let mut in_commands_section = false; for line in lines { - if has_parsed_subcommand_header { - let (command, _) = line.trim().split_once(' ').unwrap_or(("", "")); - possible_commands.push(command.to_string()); + if line.trim() == "Commands:" { + // Start of commands section + in_commands_section = true; + continue; } - if line == "SUBCOMMANDS:" { - has_parsed_subcommand_header = true; + + if in_commands_section { + if line.trim().is_empty() || line.trim().starts_with("Options:") { + // End of commands section + break; + } + // Extract command name (first word of the line) + if let Some(command) = line.split_whitespace().next() { + possible_commands.push(command.to_string()); + } } } - possible_commands }