Convert .yaml extension to .yml Fix #43
This commit is contained in:
parent
138167bbcc
commit
a0b0842273
|
@ -34,9 +34,9 @@ use std::error::Error;
|
||||||
pub(crate) mod runtime;
|
pub(crate) mod runtime;
|
||||||
|
|
||||||
// TODO: add documentation link
|
// TODO: add documentation link
|
||||||
const DEFAULT_CONFIG_FILE_CONTENT : &str = include_str!("../res/config.yaml");
|
const DEFAULT_CONFIG_FILE_CONTENT : &str = include_str!("../res/config.yml");
|
||||||
|
|
||||||
const DEFAULT_CONFIG_FILE_NAME : &str = "default.yaml";
|
const DEFAULT_CONFIG_FILE_NAME : &str = "default.yml";
|
||||||
|
|
||||||
// Default values for primitives
|
// Default values for primitives
|
||||||
fn default_name() -> String{ "default".to_owned() }
|
fn default_name() -> String{ "default".to_owned() }
|
||||||
|
@ -110,7 +110,7 @@ macro_rules! validate_field {
|
||||||
if field_name.starts_with("self.") {
|
if field_name.starts_with("self.") {
|
||||||
field_name = &field_name[5..]; // Remove the 'self.' prefix
|
field_name = &field_name[5..]; // Remove the 'self.' prefix
|
||||||
}
|
}
|
||||||
error!("Validation error, parameter '{}' is reserved and can be only used in the default.yaml config file", field_name);
|
error!("Validation error, parameter '{}' is reserved and can be only used in the default.yml config file", field_name);
|
||||||
$result = false;
|
$result = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -205,12 +205,12 @@ impl ConfigSet {
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
|
|
||||||
// Skip the default one, already loaded
|
// Skip the default one, already loaded
|
||||||
if path.file_name().unwrap_or("".as_ref()) == "default.yaml" {
|
if path.file_name().unwrap_or("".as_ref()) == "default.yml" {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip non-yaml config files
|
// Skip non-yaml config files
|
||||||
if path.extension().unwrap_or_default().to_str().unwrap_or_default() != "yaml" {
|
if path.extension().unwrap_or_default().to_str().unwrap_or_default() != "yml" {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,8 +343,8 @@ mod tests {
|
||||||
use tempfile::{NamedTempFile, TempDir};
|
use tempfile::{NamedTempFile, TempDir};
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
|
|
||||||
const TEST_WORKING_CONFIG_FILE : &str = include_str!("../res/test/working_config.yaml");
|
const TEST_WORKING_CONFIG_FILE : &str = include_str!("../res/test/working_config.yml");
|
||||||
const TEST_CONFIG_FILE_WITH_BAD_YAML : &str = include_str!("../res/test/config_with_bad_yaml.yaml");
|
const TEST_CONFIG_FILE_WITH_BAD_YAML : &str = include_str!("../res/test/config_with_bad_yaml.yml");
|
||||||
|
|
||||||
// Test Configs
|
// Test Configs
|
||||||
|
|
||||||
|
@ -516,7 +516,7 @@ mod tests {
|
||||||
let default_path = tmp_dir.path().join(DEFAULT_CONFIG_FILE_NAME);
|
let default_path = tmp_dir.path().join(DEFAULT_CONFIG_FILE_NAME);
|
||||||
fs::write(default_path, DEFAULT_CONFIG_FILE_CONTENT);
|
fs::write(default_path, DEFAULT_CONFIG_FILE_CONTENT);
|
||||||
|
|
||||||
let specific_path = tmp_dir.path().join("specific.yaml");
|
let specific_path = tmp_dir.path().join("specific.yml");
|
||||||
let specific_path_copy = specific_path.clone();
|
let specific_path_copy = specific_path.clone();
|
||||||
fs::write(specific_path, r###"
|
fs::write(specific_path, r###"
|
||||||
config_caching_interval: 10000
|
config_caching_interval: 10000
|
||||||
|
@ -533,7 +533,7 @@ mod tests {
|
||||||
let default_path = tmp_dir.path().join(DEFAULT_CONFIG_FILE_NAME);
|
let default_path = tmp_dir.path().join(DEFAULT_CONFIG_FILE_NAME);
|
||||||
fs::write(default_path, DEFAULT_CONFIG_FILE_CONTENT);
|
fs::write(default_path, DEFAULT_CONFIG_FILE_CONTENT);
|
||||||
|
|
||||||
let specific_path = tmp_dir.path().join("specific.yaml");
|
let specific_path = tmp_dir.path().join("specific.yml");
|
||||||
let specific_path_copy = specific_path.clone();
|
let specific_path_copy = specific_path.clone();
|
||||||
fs::write(specific_path, r###"
|
fs::write(specific_path, r###"
|
||||||
backend: Clipboard
|
backend: Clipboard
|
||||||
|
@ -564,11 +564,11 @@ mod tests {
|
||||||
fn test_config_set_specific_file_duplicate_name() {
|
fn test_config_set_specific_file_duplicate_name() {
|
||||||
let tmp_dir = create_temp_espanso_directory();
|
let tmp_dir = create_temp_espanso_directory();
|
||||||
|
|
||||||
let specific_path = create_temp_file_in_dir(&tmp_dir, "specific.yaml", r###"
|
let specific_path = create_temp_file_in_dir(&tmp_dir, "specific.yml", r###"
|
||||||
name: specific1
|
name: specific1
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
let specific_path2 = create_temp_file_in_dir(&tmp_dir, "specific2.yaml", r###"
|
let specific_path2 = create_temp_file_in_dir(&tmp_dir, "specific2.yml", r###"
|
||||||
name: specific1
|
name: specific1
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
|
@ -589,7 +589,7 @@ mod tests {
|
||||||
replace: "Bob"
|
replace: "Bob"
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
let specific_path = tmp_dir.path().join("specific.yaml");
|
let specific_path = tmp_dir.path().join("specific.yml");
|
||||||
let specific_path_copy = specific_path.clone();
|
let specific_path_copy = specific_path.clone();
|
||||||
fs::write(specific_path, r###"
|
fs::write(specific_path, r###"
|
||||||
name: specific1
|
name: specific1
|
||||||
|
@ -620,7 +620,7 @@ mod tests {
|
||||||
replace: "Bob"
|
replace: "Bob"
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
let specific_path = tmp_dir.path().join("specific.yaml");
|
let specific_path = tmp_dir.path().join("specific.yml");
|
||||||
let specific_path_copy = specific_path.clone();
|
let specific_path_copy = specific_path.clone();
|
||||||
fs::write(specific_path, r###"
|
fs::write(specific_path, r###"
|
||||||
name: specific1
|
name: specific1
|
||||||
|
@ -650,7 +650,7 @@ mod tests {
|
||||||
replace: "Bob"
|
replace: "Bob"
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
let specific_path = tmp_dir.path().join("specific.yaml");
|
let specific_path = tmp_dir.path().join("specific.yml");
|
||||||
let specific_path_copy = specific_path.clone();
|
let specific_path_copy = specific_path.clone();
|
||||||
fs::write(specific_path, r###"
|
fs::write(specific_path, r###"
|
||||||
name: specific1
|
name: specific1
|
||||||
|
|
|
@ -252,18 +252,18 @@ mod tests {
|
||||||
fn test_runtime_constructor_regex_load_correctly() {
|
fn test_runtime_constructor_regex_load_correctly() {
|
||||||
let tmp_dir = create_temp_espanso_directory();
|
let tmp_dir = create_temp_espanso_directory();
|
||||||
|
|
||||||
let specific_path = create_temp_file_in_dir(&tmp_dir, "specific.yaml", r###"
|
let specific_path = create_temp_file_in_dir(&tmp_dir, "specific.yml", r###"
|
||||||
name: myname1
|
name: myname1
|
||||||
filter_exec: "Title"
|
filter_exec: "Title"
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
let specific_path2 = create_temp_file_in_dir(&tmp_dir, "specific2.yaml", r###"
|
let specific_path2 = create_temp_file_in_dir(&tmp_dir, "specific2.yml", r###"
|
||||||
name: myname2
|
name: myname2
|
||||||
filter_title: "Yeah"
|
filter_title: "Yeah"
|
||||||
filter_class: "Car"
|
filter_class: "Car"
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
let specific_path3 = create_temp_file_in_dir(&tmp_dir, "specific3.yaml", r###"
|
let specific_path3 = create_temp_file_in_dir(&tmp_dir, "specific3.yml", r###"
|
||||||
name: myname3
|
name: myname3
|
||||||
filter_title: "Nice"
|
filter_title: "Nice"
|
||||||
"###);
|
"###);
|
||||||
|
@ -303,18 +303,18 @@ mod tests {
|
||||||
fn test_runtime_constructor_malformed_regexes_are_ignored() {
|
fn test_runtime_constructor_malformed_regexes_are_ignored() {
|
||||||
let tmp_dir = create_temp_espanso_directory();
|
let tmp_dir = create_temp_espanso_directory();
|
||||||
|
|
||||||
let specific_path = create_temp_file_in_dir(&tmp_dir, "specific.yaml", r###"
|
let specific_path = create_temp_file_in_dir(&tmp_dir, "specific.yml", r###"
|
||||||
name: myname1
|
name: myname1
|
||||||
filter_exec: "[`-_]"
|
filter_exec: "[`-_]"
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
let specific_path2 = create_temp_file_in_dir(&tmp_dir, "specific2.yaml", r###"
|
let specific_path2 = create_temp_file_in_dir(&tmp_dir, "specific2.yml", r###"
|
||||||
name: myname2
|
name: myname2
|
||||||
filter_title: "[`-_]"
|
filter_title: "[`-_]"
|
||||||
filter_class: "Car"
|
filter_class: "Car"
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
let specific_path3 = create_temp_file_in_dir(&tmp_dir, "specific3.yaml", r###"
|
let specific_path3 = create_temp_file_in_dir(&tmp_dir, "specific3.yml", r###"
|
||||||
name: myname3
|
name: myname3
|
||||||
filter_title: "Nice"
|
filter_title: "Nice"
|
||||||
"###);
|
"###);
|
||||||
|
@ -354,7 +354,7 @@ mod tests {
|
||||||
fn test_runtime_calculate_active_config_specific_title_match() {
|
fn test_runtime_calculate_active_config_specific_title_match() {
|
||||||
let tmp_dir = create_temp_espanso_directory();
|
let tmp_dir = create_temp_espanso_directory();
|
||||||
|
|
||||||
let specific_path = create_temp_file_in_dir(&tmp_dir, "specific.yaml", r###"
|
let specific_path = create_temp_file_in_dir(&tmp_dir, "specific.yml", r###"
|
||||||
name: chrome
|
name: chrome
|
||||||
filter_title: "Chrome"
|
filter_title: "Chrome"
|
||||||
"###);
|
"###);
|
||||||
|
@ -372,7 +372,7 @@ mod tests {
|
||||||
fn test_runtime_calculate_active_config_specific_class_match() {
|
fn test_runtime_calculate_active_config_specific_class_match() {
|
||||||
let tmp_dir = create_temp_espanso_directory();
|
let tmp_dir = create_temp_espanso_directory();
|
||||||
|
|
||||||
let specific_path = create_temp_file_in_dir(&tmp_dir, "specific.yaml", r###"
|
let specific_path = create_temp_file_in_dir(&tmp_dir, "specific.yml", r###"
|
||||||
name: chrome
|
name: chrome
|
||||||
filter_class: "Chrome"
|
filter_class: "Chrome"
|
||||||
"###);
|
"###);
|
||||||
|
@ -390,7 +390,7 @@ mod tests {
|
||||||
fn test_runtime_calculate_active_config_specific_exec_match() {
|
fn test_runtime_calculate_active_config_specific_exec_match() {
|
||||||
let tmp_dir = create_temp_espanso_directory();
|
let tmp_dir = create_temp_espanso_directory();
|
||||||
|
|
||||||
let specific_path = create_temp_file_in_dir(&tmp_dir, "specific.yaml", r###"
|
let specific_path = create_temp_file_in_dir(&tmp_dir, "specific.yml", r###"
|
||||||
name: chrome
|
name: chrome
|
||||||
filter_exec: "chrome.exe"
|
filter_exec: "chrome.exe"
|
||||||
"###);
|
"###);
|
||||||
|
@ -408,7 +408,7 @@ mod tests {
|
||||||
fn test_runtime_calculate_active_config_specific_multi_filter_match() {
|
fn test_runtime_calculate_active_config_specific_multi_filter_match() {
|
||||||
let tmp_dir = create_temp_espanso_directory();
|
let tmp_dir = create_temp_espanso_directory();
|
||||||
|
|
||||||
let specific_path = create_temp_file_in_dir(&tmp_dir, "specific.yaml", r###"
|
let specific_path = create_temp_file_in_dir(&tmp_dir, "specific.yml", r###"
|
||||||
name: chrome
|
name: chrome
|
||||||
filter_class: Browser
|
filter_class: Browser
|
||||||
filter_exec: "firefox.exe"
|
filter_exec: "firefox.exe"
|
||||||
|
@ -428,7 +428,7 @@ mod tests {
|
||||||
fn test_runtime_calculate_active_config_no_match() {
|
fn test_runtime_calculate_active_config_no_match() {
|
||||||
let tmp_dir = create_temp_espanso_directory();
|
let tmp_dir = create_temp_espanso_directory();
|
||||||
|
|
||||||
let specific_path = create_temp_file_in_dir(&tmp_dir, "specific.yaml", r###"
|
let specific_path = create_temp_file_in_dir(&tmp_dir, "specific.yml", r###"
|
||||||
name: firefox
|
name: firefox
|
||||||
filter_title: "Firefox"
|
filter_title: "Firefox"
|
||||||
"###);
|
"###);
|
||||||
|
@ -447,7 +447,7 @@ mod tests {
|
||||||
fn test_runtime_active_config_cache() {
|
fn test_runtime_active_config_cache() {
|
||||||
let tmp_dir = create_temp_espanso_directory();
|
let tmp_dir = create_temp_espanso_directory();
|
||||||
|
|
||||||
let specific_path = create_temp_file_in_dir(&tmp_dir, "specific.yaml", r###"
|
let specific_path = create_temp_file_in_dir(&tmp_dir, "specific.yml", r###"
|
||||||
name: firefox
|
name: firefox
|
||||||
filter_title: "Firefox"
|
filter_title: "Firefox"
|
||||||
"###);
|
"###);
|
||||||
|
|
|
@ -71,7 +71,7 @@ fn main() {
|
||||||
.short("c")
|
.short("c")
|
||||||
.long("config")
|
.long("config")
|
||||||
.value_name("FILE")
|
.value_name("FILE")
|
||||||
.help("Sets a custom config directory. If not specified, reads the default $HOME/.espanso/default.yaml file, creating it if not present.")
|
.help("Sets a custom config directory. If not specified, reads the default $HOME/.espanso/default.yml file, creating it if not present.")
|
||||||
.takes_value(true))
|
.takes_value(true))
|
||||||
.arg(Arg::with_name("v")
|
.arg(Arg::with_name("v")
|
||||||
.short("v")
|
.short("v")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user