mirror of
https://github.com/veeso/termscp.git
synced 2026-04-05 09:41:53 -07:00
lint
This commit is contained in:
@@ -46,7 +46,7 @@ impl SetupActivity {
|
||||
// Collect input values if in theme form
|
||||
if self.layout == ViewLayout::Theme {
|
||||
self.collect_styles()
|
||||
.map_err(|e| format!("'{:?}' has an invalid color", e))?;
|
||||
.map_err(|e| format!("'{e:?}' has an invalid color"))?;
|
||||
}
|
||||
// save theme
|
||||
self.save_theme()
|
||||
@@ -59,7 +59,7 @@ impl SetupActivity {
|
||||
ViewLayout::SetupForm => self.collect_input_values(),
|
||||
ViewLayout::Theme => self
|
||||
.collect_styles()
|
||||
.map_err(|e| format!("'{:?}' has an invalid color", e))?,
|
||||
.map_err(|e| format!("'{e:?}' has an invalid color"))?,
|
||||
_ => {}
|
||||
}
|
||||
// Update view
|
||||
@@ -113,7 +113,7 @@ impl SetupActivity {
|
||||
Err(err) => {
|
||||
// Report error
|
||||
self.mount_error(
|
||||
format!("Could not get ssh key \"{}\": {}", key, err).as_str(),
|
||||
format!("Could not get ssh key \"{key}\": {err}").as_str(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -134,7 +134,7 @@ impl SetupActivity {
|
||||
};
|
||||
// Prepare text editor
|
||||
env::set_var("EDITOR", self.config().get_text_editor());
|
||||
let placeholder: String = format!("# Type private SSH key for {}@{}\n", username, host);
|
||||
let placeholder: String = format!("# Type private SSH key for {username}@{host}\n");
|
||||
// Put input mode back to normal
|
||||
if let Err(err) = self.context_mut().terminal().disable_raw_mode() {
|
||||
error!("Could not disable raw mode: {}", err);
|
||||
@@ -159,14 +159,14 @@ impl SetupActivity {
|
||||
self.add_ssh_key(host.as_str(), username.as_str(), rsa_key.as_str())
|
||||
{
|
||||
self.mount_error(
|
||||
format!("Could not create new private key: {}", err).as_str(),
|
||||
format!("Could not create new private key: {err}").as_str(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
// Report error
|
||||
self.mount_error(format!("Could not write private key to file: {}", err).as_str());
|
||||
self.mount_error(format!("Could not write private key to file: {err}").as_str());
|
||||
}
|
||||
}
|
||||
// Restore terminal
|
||||
|
||||
@@ -15,7 +15,7 @@ impl SetupActivity {
|
||||
Ok(_) => Ok(()),
|
||||
Err(err) => {
|
||||
error!("Could not save configuration: {}", err);
|
||||
Err(format!("Could not save configuration: {}", err))
|
||||
Err(format!("Could not save configuration: {err}"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,21 +25,21 @@ impl SetupActivity {
|
||||
pub(super) fn reset_config_changes(&mut self) -> Result<(), String> {
|
||||
self.config_mut()
|
||||
.read_config()
|
||||
.map_err(|e| format!("Could not reload configuration: {}", e))
|
||||
.map_err(|e| format!("Could not reload configuration: {e}"))
|
||||
}
|
||||
|
||||
/// Save theme to file
|
||||
pub(super) fn save_theme(&mut self) -> Result<(), String> {
|
||||
self.theme_provider()
|
||||
.save()
|
||||
.map_err(|e| format!("Could not save theme: {}", e))
|
||||
.map_err(|e| format!("Could not save theme: {e}"))
|
||||
}
|
||||
|
||||
/// Reset changes committed to theme
|
||||
pub(super) fn reset_theme_changes(&mut self) -> Result<(), String> {
|
||||
self.theme_provider()
|
||||
.load()
|
||||
.map_err(|e| format!("Could not restore theme: {}", e))
|
||||
.map_err(|e| format!("Could not restore theme: {e}"))
|
||||
}
|
||||
|
||||
/// Delete ssh key from config cli
|
||||
@@ -47,8 +47,7 @@ impl SetupActivity {
|
||||
match self.config_mut().del_ssh_key(host, username) {
|
||||
Ok(_) => Ok(()),
|
||||
Err(err) => Err(format!(
|
||||
"Could not delete ssh key \"{}@{}\": {}",
|
||||
host, username, err
|
||||
"Could not delete ssh key \"{host}@{username}\": {err}"
|
||||
)),
|
||||
}
|
||||
}
|
||||
@@ -80,11 +79,11 @@ impl SetupActivity {
|
||||
Some((_, _, key_path)) => {
|
||||
match edit::edit_file(key_path.as_path()) {
|
||||
Ok(_) => Ok(()),
|
||||
Err(err) => Err(format!("Could not edit ssh key: {}", err)),
|
||||
Err(err) => Err(format!("Could not edit ssh key: {err}")),
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(err) => Err(format!("Could not read ssh key: {}", err)),
|
||||
Err(err) => Err(format!("Could not read ssh key: {err}")),
|
||||
}
|
||||
}
|
||||
None => Ok(()),
|
||||
@@ -119,6 +118,6 @@ impl SetupActivity {
|
||||
) -> Result<(), String> {
|
||||
self.config_mut()
|
||||
.add_ssh_key(host, username, rsa_key)
|
||||
.map_err(|e| format!("Could not add SSH key: {}", e))
|
||||
.map_err(|e| format!("Could not add SSH key: {e}"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ impl Activity for SetupActivity {
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
self.mount_error(format!("Application error: {}", err));
|
||||
self.mount_error(format!("Application error: {err}"));
|
||||
}
|
||||
}
|
||||
// View
|
||||
|
||||
@@ -124,7 +124,7 @@ impl SetupActivity {
|
||||
.iter_ssh_keys()
|
||||
.map(|x| {
|
||||
let (addr, username, _) = self.config().get_ssh_key(x).ok().unwrap().unwrap();
|
||||
format!("{} at {}", username, addr)
|
||||
format!("{username} at {addr}")
|
||||
})
|
||||
.collect();
|
||||
assert!(self
|
||||
|
||||
Reference in New Issue
Block a user