Move config to external file

This commit is contained in:
Federico Terzi 2019-09-04 20:30:38 +02:00
parent 0be2c9cb84
commit cafc3c158f
2 changed files with 53 additions and 52 deletions

View File

@ -7,6 +7,9 @@ use std::fs::File;
use std::io::Read;
use serde::{Serialize, Deserialize};
// TODO: add documentation link
const DEFAULT_CONFIG_FILE_CONTENT : &str = include_str!("res/config.yaml");
#[derive(Debug, Serialize, Deserialize)]
pub struct Configs {
pub matches: Vec<Match>
@ -44,55 +47,4 @@ impl Configs {
panic!("Could not generate default position for config file");
}
}
}
// TODO: add documentation link
const DEFAULT_CONFIG_FILE_CONTENT : &str = r###"# espanso configuration file
# This is the default configuration file, change it as you like it
# You can refer to the official documentation:
# Matches are the substitution rules, when you type the "trigger" string
# it gets replaced by the "replace" string.
matches:
# Default
- trigger: ":espanso"
replace: "Hi there!"
# Emojis
- trigger: ":lol"
replace: "😂"
- trigger: ":llol"
replace: "😂😂😂😂"
- trigger: ":sad"
replace: ""
- trigger: ":ssad"
replace: "☹☹☹☹"
# Accented letters
- trigger: "e'"
replace: "è"
- trigger: "e/"
replace: "é"
- trigger: "a'"
replace: "à"
- trigger: "i'"
replace: "ì"
- trigger: "o'"
replace: "ò"
- trigger: "u'"
replace: "ù"
# Capital accented letters
- trigger: "E'"
replace: "È"
- trigger: "E/"
replace: "É"
- trigger: "A'"
replace: "À"
- trigger: "I'"
replace: "Ì"
- trigger: "O'"
replace: "Ò"
- trigger: "U'"
replace: "Ù"
"###;
}

49
src/res/config.yaml Normal file
View File

@ -0,0 +1,49 @@
# espanso configuration file
# This is the default configuration file, change it as you like it
# You can refer to the official documentation:
# Matches are the substitution rules, when you type the "trigger" string
# it gets replaced by the "replace" string.
matches:
# Default
- trigger: ":espanso"
replace: "Hi there!"
# Emojis
- trigger: ":lol"
replace: "😂"
- trigger: ":llol"
replace: "😂😂😂😂"
- trigger: ":sad"
replace: "☹"
- trigger: ":ssad"
replace: "☹☹☹☹"
# Accented letters
- trigger: "e'"
replace: "è"
- trigger: "e/"
replace: "é"
- trigger: "a'"
replace: "à"
- trigger: "i'"
replace: "ì"
- trigger: "o'"
replace: "ò"
- trigger: "u'"
replace: "ù"
# Capital accented letters
- trigger: "E'"
replace: "È"
- trigger: "E/"
replace: "É"
- trigger: "A'"
replace: "À"
- trigger: "I'"
replace: "Ì"
- trigger: "O'"
replace: "Ò"
- trigger: "U'"
replace: "Ù"