style(migrate): fix formatting
This commit is contained in:
parent
b0e836a7e7
commit
e227fae326
|
@ -42,7 +42,9 @@ pub fn convert(input_files: HashMap<String, Hash>) -> HashMap<String, ConvertedF
|
||||||
|
|
||||||
if let Some(parent) = yaml_parent {
|
if let Some(parent) = yaml_parent {
|
||||||
if parent != "default" {
|
if parent != "default" {
|
||||||
eprintln!("WARNING: nested 'parent' instructions are not currently supported by the migration tool");
|
eprintln!(
|
||||||
|
"WARNING: nested 'parent' instructions are not currently supported by the migration tool"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,13 +63,14 @@ pub fn convert(input_files: HashMap<String, Hash>) -> HashMap<String, ConvertedF
|
||||||
|
|
||||||
let output_yaml = output_files
|
let output_yaml = output_files
|
||||||
.entry(match_output_path.clone())
|
.entry(match_output_path.clone())
|
||||||
.or_insert(ConvertedFile {
|
.or_insert(ConvertedFile {
|
||||||
origin: input_path.to_string(),
|
origin: input_path.to_string(),
|
||||||
content: Hash::new(),
|
content: Hash::new(),
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some(global_vars) = yaml_global_vars {
|
if let Some(global_vars) = yaml_global_vars {
|
||||||
let output_global_vars = output_yaml.content
|
let output_global_vars = output_yaml
|
||||||
|
.content
|
||||||
.entry(Yaml::String("global_vars".to_string()))
|
.entry(Yaml::String("global_vars".to_string()))
|
||||||
.or_insert(Yaml::Array(Vec::new()));
|
.or_insert(Yaml::Array(Vec::new()));
|
||||||
if let Yaml::Array(out_global_vars) = output_global_vars {
|
if let Yaml::Array(out_global_vars) = output_global_vars {
|
||||||
|
@ -78,7 +81,8 @@ pub fn convert(input_files: HashMap<String, Hash>) -> HashMap<String, ConvertedF
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(matches) = yaml_matches {
|
if let Some(matches) = yaml_matches {
|
||||||
let output_matches = output_yaml.content
|
let output_matches = output_yaml
|
||||||
|
.content
|
||||||
.entry(Yaml::String("matches".to_string()))
|
.entry(Yaml::String("matches".to_string()))
|
||||||
.or_insert(Yaml::Array(Vec::new()));
|
.or_insert(Yaml::Array(Vec::new()));
|
||||||
if let Yaml::Array(out_matches) = output_matches {
|
if let Yaml::Array(out_matches) = output_matches {
|
||||||
|
@ -123,9 +127,15 @@ pub fn convert(input_files: HashMap<String, Hash>) -> HashMap<String, ConvertedF
|
||||||
"paste_shortcut",
|
"paste_shortcut",
|
||||||
|val| match val {
|
|val| match val {
|
||||||
Yaml::String(shortcut) if shortcut == "CtrlV" => Some(Yaml::String("CTRL+V".to_string())),
|
Yaml::String(shortcut) if shortcut == "CtrlV" => Some(Yaml::String("CTRL+V".to_string())),
|
||||||
Yaml::String(shortcut) if shortcut == "CtrlShiftV" => Some(Yaml::String("CTRL+SHIFT+V".to_string())),
|
Yaml::String(shortcut) if shortcut == "CtrlShiftV" => {
|
||||||
Yaml::String(shortcut) if shortcut == "ShiftInsert" => Some(Yaml::String("SHIFT+INSERT".to_string())),
|
Some(Yaml::String("CTRL+SHIFT+V".to_string()))
|
||||||
Yaml::String(shortcut) if shortcut == "CtrlAltV" => Some(Yaml::String("CTRL+ALT+V".to_string())),
|
}
|
||||||
|
Yaml::String(shortcut) if shortcut == "ShiftInsert" => {
|
||||||
|
Some(Yaml::String("SHIFT+INSERT".to_string()))
|
||||||
|
}
|
||||||
|
Yaml::String(shortcut) if shortcut == "CtrlAltV" => {
|
||||||
|
Some(Yaml::String("CTRL+ALT+V".to_string()))
|
||||||
|
}
|
||||||
Yaml::String(shortcut) if shortcut == "MetaV" => Some(Yaml::String("META+V".to_string())),
|
Yaml::String(shortcut) if shortcut == "MetaV" => Some(Yaml::String("META+V".to_string())),
|
||||||
Yaml::String(_) => None,
|
Yaml::String(_) => None,
|
||||||
_ => None,
|
_ => None,
|
||||||
|
@ -136,10 +146,20 @@ pub fn convert(input_files: HashMap<String, Hash>) -> HashMap<String, ConvertedF
|
||||||
//copy_field_if_present(yaml, "config_caching_interval", &mut output_yaml, "config_caching_interval");
|
//copy_field_if_present(yaml, "config_caching_interval", &mut output_yaml, "config_caching_interval");
|
||||||
//copy_field_if_present(yaml, "use_system_agent", &mut output_yaml, "use_system_agent");
|
//copy_field_if_present(yaml, "use_system_agent", &mut output_yaml, "use_system_agent");
|
||||||
|
|
||||||
copy_field_if_present(yaml, "secure_input_notification", &mut output_yaml, "secure_input_notification");
|
copy_field_if_present(
|
||||||
|
yaml,
|
||||||
|
"secure_input_notification",
|
||||||
|
&mut output_yaml,
|
||||||
|
"secure_input_notification",
|
||||||
|
);
|
||||||
copy_field_if_present(yaml, "toggle_interval", &mut output_yaml, "toggle_interval");
|
copy_field_if_present(yaml, "toggle_interval", &mut output_yaml, "toggle_interval");
|
||||||
copy_field_if_present(yaml, "toggle_key", &mut output_yaml, "toggle_key");
|
copy_field_if_present(yaml, "toggle_key", &mut output_yaml, "toggle_key");
|
||||||
copy_field_if_present(yaml, "preserve_clipboard", &mut output_yaml, "preserve_clipboard");
|
copy_field_if_present(
|
||||||
|
yaml,
|
||||||
|
"preserve_clipboard",
|
||||||
|
&mut output_yaml,
|
||||||
|
"preserve_clipboard",
|
||||||
|
);
|
||||||
copy_field_if_present(yaml, "backspace_limit", &mut output_yaml, "backspace_limit");
|
copy_field_if_present(yaml, "backspace_limit", &mut output_yaml, "backspace_limit");
|
||||||
map_field_if_present(
|
map_field_if_present(
|
||||||
yaml,
|
yaml,
|
||||||
|
@ -156,13 +176,26 @@ pub fn convert(input_files: HashMap<String, Hash>) -> HashMap<String, ConvertedF
|
||||||
copy_field_if_present(yaml, "auto_restart", &mut output_yaml, "auto_restart");
|
copy_field_if_present(yaml, "auto_restart", &mut output_yaml, "auto_restart");
|
||||||
copy_field_if_present(yaml, "undo_backspace", &mut output_yaml, "undo_backspace");
|
copy_field_if_present(yaml, "undo_backspace", &mut output_yaml, "undo_backspace");
|
||||||
copy_field_if_present(yaml, "show_icon", &mut output_yaml, "show_icon");
|
copy_field_if_present(yaml, "show_icon", &mut output_yaml, "show_icon");
|
||||||
copy_field_if_present(yaml, "show_notifications", &mut output_yaml, "show_notifications");
|
copy_field_if_present(
|
||||||
|
yaml,
|
||||||
|
"show_notifications",
|
||||||
|
&mut output_yaml,
|
||||||
|
"show_notifications",
|
||||||
|
);
|
||||||
copy_field_if_present(yaml, "inject_delay", &mut output_yaml, "inject_delay");
|
copy_field_if_present(yaml, "inject_delay", &mut output_yaml, "inject_delay");
|
||||||
copy_field_if_present(yaml, "restore_clipboard_delay", &mut output_yaml, "restore_clipboard_delay");
|
copy_field_if_present(
|
||||||
|
yaml,
|
||||||
|
"restore_clipboard_delay",
|
||||||
|
&mut output_yaml,
|
||||||
|
"restore_clipboard_delay",
|
||||||
|
);
|
||||||
copy_field_if_present(yaml, "backspace_delay", &mut output_yaml, "key_delay");
|
copy_field_if_present(yaml, "backspace_delay", &mut output_yaml, "key_delay");
|
||||||
copy_field_if_present(yaml, "word_separators", &mut output_yaml, "word_separators");
|
copy_field_if_present(yaml, "word_separators", &mut output_yaml, "word_separators");
|
||||||
|
|
||||||
if yaml.get(&Yaml::String("enable_passive".to_string())).is_some() {
|
if yaml
|
||||||
|
.get(&Yaml::String("enable_passive".to_string()))
|
||||||
|
.is_some()
|
||||||
|
{
|
||||||
eprintln!("WARNING: passive-mode directives were detected, but passive-mode is not supported anymore.");
|
eprintln!("WARNING: passive-mode directives were detected, but passive-mode is not supported anymore.");
|
||||||
eprintln!("Please follow this issue to discover the alternatives: https://github.com/federico-terzi/espanso/issues/540");
|
eprintln!("Please follow this issue to discover the alternatives: https://github.com/federico-terzi/espanso/issues/540");
|
||||||
}
|
}
|
||||||
|
@ -183,10 +216,13 @@ pub fn convert(input_files: HashMap<String, Hash>) -> HashMap<String, ConvertedF
|
||||||
output_yaml.insert(Yaml::String(key_name.to_string()), Yaml::Array(includes));
|
output_yaml.insert(Yaml::String(key_name.to_string()), Yaml::Array(includes));
|
||||||
}
|
}
|
||||||
|
|
||||||
output_files.insert(config_output_path, ConvertedFile {
|
output_files.insert(
|
||||||
origin: input_path,
|
config_output_path,
|
||||||
content: output_yaml,
|
ConvertedFile {
|
||||||
});
|
origin: input_path,
|
||||||
|
content: output_yaml,
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,11 @@ fn render_file(file: ConvertedFile) -> Result<String> {
|
||||||
|
|
||||||
let lines: Vec<&str> = dump_str.lines().collect();
|
let lines: Vec<&str> = dump_str.lines().collect();
|
||||||
let header = format!("# Original file: {}", file.origin);
|
let header = format!("# Original file: {}", file.origin);
|
||||||
let mut output_lines: Vec<&str> = vec!["# Automatically generated by espanso migration tool", &header, ""];
|
let mut output_lines: Vec<&str> = vec![
|
||||||
|
"# Automatically generated by espanso migration tool",
|
||||||
|
&header,
|
||||||
|
"",
|
||||||
|
];
|
||||||
if !lines.is_empty() {
|
if !lines.is_empty() {
|
||||||
output_lines.extend(&lines[1..]);
|
output_lines.extend(&lines[1..]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user