opt2doc/
args.rs

1use std::path::PathBuf;
2
3use clap::{command, Parser, ValueEnum};
4
5#[derive(Parser, Debug)]
6#[command(version, about, long_about = None)]
7pub struct Args {
8    /// Optional name to operate on
9    name: Option<String>,
10    /// Repo dir to search for the cargo workspace.
11    #[arg(long, default_value = ".")]
12    pub repo: PathBuf,
13
14    /// The path output files.
15    #[arg(short, long, default_value = "target/opt2doc/")]
16    pub output: PathBuf,
17
18    /// Format to render.
19    #[arg(short, long, value_enum)]
20    pub render: RenderFormat,
21
22    /// Name of the root option struct. Setting this will ignore all other options
23    /// that are not accessible from the given root.
24    #[arg(long)]
25    pub root: Option<String>,
26
27    /// The path of config file. E.g., `./opt2doc.toml`.
28    #[arg(short, long)]
29    pub config: Option<PathBuf>,
30}
31
32#[derive(Default, Parser, Debug, Clone, ValueEnum)]
33pub enum RenderFormat {
34    /// Do nothing. Only the JSON metadata file will be generated.
35    #[default]
36    None,
37    /// Render a markdown file which contains a table of all options.
38    Markdown,
39    /// Render a toml file with all options set to default.
40    Toml,
41    /// Render a yaml file with all option set to default.
42    Yaml,
43    /// Render a single-page HTML file with all options.
44    Html,
45    // TODO: support more formats
46}