Extend Context to have setters for args
@@ -232,6 +232,11 @@ impl Context {
}
}
+ /// Inserts value to the command line arguments map.
+ pub fn set_arg(&mut self, key: &str, value: String) {
+ self.args.insert(String::from(key), value);
+ }
+
/// Gets multiple values of the command line argument.
pub fn arg_multiple<T: FromStr>(&self, key: &str) -> Result<Vec<T>, Box<Error>>
where
@@ -244,6 +249,11 @@ impl Context {
}
}
+ /// Inserts multiple values to the command line arguments map.
+ pub fn set_arg_multiple(&mut self, key: &str, values: Vec<String>) {
+ self.multiple_args.insert(String::from(key), values);
+ }
+
/// Gets the variable from the context.
pub fn get<'de, T: Deserialize<'de>>(&self, key: ContextKey<T>) -> Result<T, Box<Error>> {
self.get_raw(key.name())
