mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Improved getters/setters config client
This commit is contained in:
@@ -165,26 +165,19 @@ impl ConfigClient {
|
|||||||
|
|
||||||
/// ### get_file_fmt
|
/// ### get_file_fmt
|
||||||
///
|
///
|
||||||
/// Get current file fmt; if none return ""
|
/// Get current file fmt
|
||||||
pub fn get_file_fmt(&self) -> String {
|
pub fn get_file_fmt(&self) -> Option<String> {
|
||||||
match &self.config.user_interface.file_fmt {
|
self.config.user_interface.file_fmt.clone()
|
||||||
None => String::new(),
|
|
||||||
Some(s) => s.clone(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ### set_file_fmt
|
/// ### set_file_fmt
|
||||||
///
|
///
|
||||||
/// Set file fmt parameter
|
/// Set file fmt parameter
|
||||||
pub fn set_file_fmt(&mut self, s: String) {
|
pub fn set_file_fmt(&mut self, s: String) {
|
||||||
self.config.user_interface.file_fmt = Some(s);
|
self.config.user_interface.file_fmt = match s.is_empty() {
|
||||||
}
|
true => None,
|
||||||
|
false => Some(s),
|
||||||
/// ### del_file_fmt
|
};
|
||||||
///
|
|
||||||
/// Delete file fmt parameter
|
|
||||||
pub fn del_file_fmt(&mut self) {
|
|
||||||
self.config.user_interface.file_fmt = None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SSH Keys
|
// SSH Keys
|
||||||
@@ -482,12 +475,12 @@ mod tests {
|
|||||||
let mut client: ConfigClient = ConfigClient::new(cfg_path.as_path(), key_path.as_path())
|
let mut client: ConfigClient = ConfigClient::new(cfg_path.as_path(), key_path.as_path())
|
||||||
.ok()
|
.ok()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(client.get_file_fmt(), String::from(""));
|
assert_eq!(client.get_file_fmt(), None);
|
||||||
client.set_file_fmt(String::from("{NAME}"));
|
client.set_file_fmt(String::from("{NAME}"));
|
||||||
assert_eq!(client.get_file_fmt(), String::from("{NAME}"));
|
assert_eq!(client.get_file_fmt().unwrap(), String::from("{NAME}"));
|
||||||
// Delete
|
// Delete
|
||||||
client.del_file_fmt();
|
client.set_file_fmt(String::from(""));
|
||||||
assert_eq!(client.get_file_fmt(), String::from(""));
|
assert_eq!(client.get_file_fmt(), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user