Registers a named option that requires a value (i.e. `key=value`). Option names must not contain `"`, `[`, `]`, `=`, or `,`. Returns `&mut Self` for chaining. # Panics Panics if the option name contains a forbidden character.
(&mut self, option: &str)
| 182 | /// |
| 183 | /// Panics if the option name contains a forbidden character. |
| 184 | pub fn add(&mut self, option: &str) -> &mut Self { |
| 185 | // Check that option=value has balanced |
| 186 | // quotes and brackets iff value does. |
| 187 | assert!( |
| 188 | !option.contains(['"', '[', ']', '=', ',']), |
| 189 | "forbidden character in option name" |
| 190 | ); |
| 191 | self.options.insert( |
| 192 | option.to_owned(), |
| 193 | OptionParserValue { |
| 194 | value: None, |
| 195 | requires_value: true, |
| 196 | }, |
| 197 | ); |
| 198 | |
| 199 | self |
| 200 | } |
| 201 | |
| 202 | /// Registers multiple value-requiring options at once. |
| 203 | /// |