feat(core): add builtin function to dump current config

This commit is contained in:
Federico Terzi 2021-07-31 22:06:39 +02:00
parent 3cdc964777
commit dcc2cd2708
2 changed files with 8 additions and 6 deletions

View File

@ -17,20 +17,22 @@
* along with espanso. If not, see <https://www.gnu.org/licenses/>. * along with espanso. If not, see <https://www.gnu.org/licenses/>.
*/ */
use crate::{cli::worker::builtin::generate_next_builtin_id, engine::event::{EventType, effect::TextInjectRequest}}; use crate::{cli::worker::builtin::generate_next_builtin_id, engine::event::{EventType, effect::{TextInjectRequest}}};
use super::BuiltInMatch; use super::BuiltInMatch;
pub fn create_match_show_active_config_info() -> BuiltInMatch { // TODO: create task that opens up a GUI with this content
pub fn create_match_paste_active_config_info() -> BuiltInMatch {
BuiltInMatch { BuiltInMatch {
id: generate_next_builtin_id(), id: generate_next_builtin_id(),
label: "Display active config information", label: "Paste active config information",
triggers: vec!["#acfg#".to_string()], triggers: vec!["#acfg#".to_string()],
action: |context| { action: |context| {
println!("active config: {:?}", context.get_active_config().label()); let dump = context.get_active_config().pretty_dump();
EventType::TextInject(TextInjectRequest { EventType::TextInject(TextInjectRequest {
text: "test".to_string(), text: dump,
force_mode: None, force_mode: None,
}) })
}, },

View File

@ -36,7 +36,7 @@ pub struct BuiltInMatch {
pub fn get_builtin_matches() -> Vec<BuiltInMatch> { pub fn get_builtin_matches() -> Vec<BuiltInMatch> {
vec![ vec![
debug::create_match_show_active_config_info(), debug::create_match_paste_active_config_info(),
] ]
} }