forc_doc/
cli.rs

1//! The command line interface for `forc doc`.
2use clap::Parser;
3use forc_pkg::source::IPFSNode;
4
5forc_util::cli_examples! {
6    crate::cli::Command {
7        [ Build the docs for a project in the current path => "forc doc"]
8        [ Build the docs for a project in the current path and open it in the browser => "forc doc --open" ]
9        [ Build the docs for a project located in another path => "forc doc --path {path}" ]
10        [ Build the docs for the current project exporting private types => "forc doc --document-private-items" ]
11        [ Build the docs offline without downloading any dependencies => "forc doc --offline" ]
12    }
13}
14
15/// Forc plugin for building a Sway package's documentation
16#[derive(Debug, Parser, Default)]
17#[clap(
18    name = "forc-doc",
19    after_help = help(),
20    version
21)]
22pub struct Command {
23    /// Path to the project.
24    ///
25    /// If not specified, current working directory will be used.
26    #[clap(short, long, alias = "manifest-path")]
27    pub path: Option<String>,
28    /// Include non-public items in the documentation.
29    #[clap(long)]
30    pub document_private_items: bool,
31    /// Open the docs in a browser after building them.
32    #[clap(long)]
33    pub open: bool,
34    /// Offline mode, prevents Forc from using the network when managing dependencies.
35    /// Meaning it will only try to use previously downloaded dependencies.
36    #[clap(long = "offline")]
37    pub offline: bool,
38    /// Requires that the Forc.lock file is up-to-date. If the lock file is missing, or it
39    /// needs to be updated, Forc will exit with an error.
40    #[clap(long)]
41    pub locked: bool,
42    /// Do not build documentation for dependencies.
43    #[clap(long)]
44    pub no_deps: bool,
45    /// The IPFS Node to use for fetching IPFS sources.
46    ///
47    /// Possible values: FUEL, PUBLIC, LOCAL, <GATEWAY_URL>
48    #[clap(long)]
49    pub ipfs_node: Option<IPFSNode>,
50    #[cfg(test)]
51    pub(crate) doc_path: Option<String>,
52    #[clap(flatten)]
53    pub experimental: sway_features::CliFields,
54    /// Silent mode. Don't output any warnings or errors to the command line.
55    #[clap(long = "silent", short = 's')]
56    pub silent: bool,
57}