bird_tool_utils_man/
section.rs

1use crate::{Flag, FlagOrOption, Opt};
2
3/// Add a custom section
4#[derive(Debug)]
5pub struct Section {
6  pub(crate) name: String,
7  pub(crate) paragraphs: Vec<String>,
8  pub(crate) flags_and_options: Vec<Box<dyn FlagOrOption>>,
9}
10
11impl Section {
12  pub fn new(name: &str) -> Self {
13    Self {
14      name: name.into(),
15      paragraphs: vec![],
16      flags_and_options: vec![],
17    }
18  }
19
20  pub fn paragraph(mut self, text: &str) -> Self {
21    self.paragraphs.push(text.into());
22    self
23  }
24
25  /// Add an flag.
26  pub fn flag(mut self, flag: Flag) -> Self {
27    self.flags_and_options.push(Box::new(flag));
28    self
29  }
30
31  /// Add an option.
32  pub fn option(mut self, opt: Opt) -> Self {
33    self.flags_and_options.push(Box::new(opt));
34    self
35  }
36}