cmd_args/option/
descriptor.rs1use std::rc::Rc;
2use crate::option;
3use std::collections::HashSet;
4
5pub struct Descriptor {
7 name: Rc<String>,
8 aliases: HashSet<String>,
9 value_type: option::Type,
10 description: String,
11}
12
13impl Descriptor {
14 pub fn new(name: &str, value_type: option::Type, description: &str) -> Self {
16 Descriptor {
17 name: Rc::new(String::from(name)),
18 aliases: HashSet::new(),
19 value_type,
20 description: String::from(description),
21 }
22 }
23
24 pub fn name(&self) -> &String {
26 &self.name
27 }
28
29 pub fn take_name(&self) -> Rc<String> {
31 Rc::clone(&self.name)
32 }
33
34 pub fn value_type(&self) -> &option::Type {
36 &self.value_type
37 }
38
39 pub fn description(&self) -> &String {
41 &self.description
42 }
43
44 pub fn add_alias(mut self, alias: &str) -> Self {
46 self.aliases.insert(String::from(alias));
47
48 self
49 }
50
51 pub fn get_aliases(&self) -> &HashSet<String> {
53 &self.aliases
54 }
55}