feat(core): wire up textview UI
This commit is contained in:
parent
fff9f63f96
commit
02ec804604
|
@ -24,6 +24,8 @@ mod form;
|
|||
#[cfg(feature = "modulo")]
|
||||
mod search;
|
||||
#[cfg(feature = "modulo")]
|
||||
mod textview;
|
||||
#[cfg(feature = "modulo")]
|
||||
mod troubleshoot;
|
||||
#[cfg(feature = "modulo")]
|
||||
mod welcome;
|
||||
|
@ -57,6 +59,10 @@ fn modulo_main(args: CliModuleArgs) -> i32 {
|
|||
return welcome::welcome_main(matches, &paths, &icon_paths);
|
||||
}
|
||||
|
||||
if let Some(matches) = cli_args.subcommand_matches("textview") {
|
||||
return textview::textview_main(matches, &icon_paths);
|
||||
}
|
||||
|
||||
if cli_args.subcommand_matches("troubleshoot").is_some() {
|
||||
return troubleshoot::troubleshoot_main(&paths, &icon_paths);
|
||||
}
|
||||
|
|
51
espanso/src/cli/modulo/textview.rs
Normal file
51
espanso/src/cli/modulo/textview.rs
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* This file is part of espanso.
|
||||
*
|
||||
* Copyright (C) 2019-2021 Federico Terzi
|
||||
*
|
||||
* espanso is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* espanso is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use crate::icon::IconPaths;
|
||||
use clap::ArgMatches;
|
||||
use espanso_modulo::textview::TextViewOptions;
|
||||
|
||||
pub fn textview_main(matches: &ArgMatches, icon_paths: &IconPaths) -> i32 {
|
||||
let title = matches.value_of("title").unwrap_or("Espanso");
|
||||
|
||||
let input_file = matches
|
||||
.value_of("input_file")
|
||||
.expect("missing input, please specify the -i option");
|
||||
let data = if input_file == "-" {
|
||||
use std::io::Read;
|
||||
let mut buffer = String::new();
|
||||
std::io::stdin()
|
||||
.read_to_string(&mut buffer)
|
||||
.expect("unable to obtain input from stdin");
|
||||
buffer
|
||||
} else {
|
||||
std::fs::read_to_string(input_file).expect("unable to read input file")
|
||||
};
|
||||
|
||||
espanso_modulo::textview::show(TextViewOptions {
|
||||
window_icon_path: icon_paths
|
||||
.wizard_icon
|
||||
.as_ref()
|
||||
.map(|path| path.to_string_lossy().to_string()),
|
||||
title: title.to_string(),
|
||||
content: data,
|
||||
});
|
||||
|
||||
0
|
||||
}
|
|
@ -292,6 +292,23 @@ For example, specifying 'email' is equivalent to 'match/email.yml'."#))
|
|||
.help("Interpret the input data as JSON"),
|
||||
),
|
||||
)
|
||||
.subcommand(
|
||||
SubCommand::with_name("textview")
|
||||
.about("Display a Text View")
|
||||
.arg(
|
||||
Arg::with_name("input_file")
|
||||
.short("i")
|
||||
.takes_value(true)
|
||||
.help("Input file or - for stdin"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("title")
|
||||
.long("title")
|
||||
.required(true)
|
||||
.takes_value(true)
|
||||
.help("Window title to display"),
|
||||
),
|
||||
)
|
||||
.subcommand(SubCommand::with_name("troubleshoot").about("Display the troubleshooting GUI"))
|
||||
.subcommand(
|
||||
SubCommand::with_name("welcome")
|
||||
|
|
Loading…
Reference in New Issue
Block a user