mirror of
https://github.com/imgurbot12/rmenu.git
synced 2025-01-27 05:18:33 +01:00
feat: added options to pass from entries
This commit is contained in:
parent
7ff9412a67
commit
7e3c6c45d8
2 changed files with 52 additions and 11 deletions
|
@ -21,6 +21,12 @@ fn parse_action(action: &str) -> Result<Action, serde_json::Error> {
|
||||||
enum Command {
|
enum Command {
|
||||||
/// Generate Complete RMenu Entry
|
/// Generate Complete RMenu Entry
|
||||||
Entry {
|
Entry {
|
||||||
|
/// Set Name of Entry
|
||||||
|
#[arg(short, long, default_value_t=String::from("main"))]
|
||||||
|
name: String,
|
||||||
|
/// Set Comment of Entry
|
||||||
|
#[arg(short, long)]
|
||||||
|
comment: Option<String>,
|
||||||
/// Precomposed Action JSON Objects
|
/// Precomposed Action JSON Objects
|
||||||
#[arg(short, long, value_parser=parse_action)]
|
#[arg(short, long, value_parser=parse_action)]
|
||||||
#[clap(required = true)]
|
#[clap(required = true)]
|
||||||
|
@ -34,6 +40,12 @@ enum Command {
|
||||||
},
|
},
|
||||||
/// Generate RMenu Entry Action Object
|
/// Generate RMenu Entry Action Object
|
||||||
Action {
|
Action {
|
||||||
|
/// Set Name of Action
|
||||||
|
#[arg(short, long, default_value_t=String::from("main"))]
|
||||||
|
name: String,
|
||||||
|
/// Set Comment of Action
|
||||||
|
#[arg(short, long)]
|
||||||
|
comment: Option<String>,
|
||||||
/// Arguments to run As Action Command
|
/// Arguments to run As Action Command
|
||||||
#[clap(required = true, value_delimiter = ' ')]
|
#[clap(required = true, value_delimiter = ' ')]
|
||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
|
@ -47,12 +59,6 @@ enum Command {
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
#[command(propagate_version = true)]
|
#[command(propagate_version = true)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// Set Name of Entry/Action
|
|
||||||
#[arg(short, long, default_value_t=String::from("main"))]
|
|
||||||
name: String,
|
|
||||||
/// Set Comment of Entry/Action
|
|
||||||
#[arg(short, long)]
|
|
||||||
comment: Option<String>,
|
|
||||||
/// Generate an Entry/Action Object
|
/// Generate an Entry/Action Object
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
command: Command,
|
command: Command,
|
||||||
|
@ -62,20 +68,27 @@ fn main() {
|
||||||
let cli = Cli::parse();
|
let cli = Cli::parse();
|
||||||
let result = match cli.command {
|
let result = match cli.command {
|
||||||
Command::Entry {
|
Command::Entry {
|
||||||
|
name,
|
||||||
|
comment,
|
||||||
actions,
|
actions,
|
||||||
icon,
|
icon,
|
||||||
icon_alt,
|
icon_alt,
|
||||||
} => serde_json::to_string(&Entry {
|
} => serde_json::to_string(&Entry {
|
||||||
name: cli.name,
|
name,
|
||||||
comment: cli.comment,
|
comment,
|
||||||
actions,
|
actions,
|
||||||
icon,
|
icon,
|
||||||
icon_alt,
|
icon_alt,
|
||||||
}),
|
}),
|
||||||
Command::Action { args, terminal } => serde_json::to_string(&Action {
|
Command::Action {
|
||||||
name: cli.name,
|
name,
|
||||||
|
comment,
|
||||||
|
args,
|
||||||
|
terminal,
|
||||||
|
} => serde_json::to_string(&Action {
|
||||||
|
name,
|
||||||
exec: Method::new(args.join(" "), terminal),
|
exec: Method::new(args.join(" "), terminal),
|
||||||
comment: cli.comment,
|
comment,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
println!("{}", result.expect("Serialization Failed"));
|
println!("{}", result.expect("Serialization Failed"));
|
||||||
|
|
|
@ -49,6 +49,7 @@ impl Action {
|
||||||
|
|
||||||
/// RMenu Menu-Entry Implementation
|
/// RMenu Menu-Entry Implementation
|
||||||
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(tag = "type", rename = "entry")]
|
||||||
pub struct Entry {
|
pub struct Entry {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub actions: Vec<Action>,
|
pub actions: Vec<Action>,
|
||||||
|
@ -80,6 +81,33 @@ impl Entry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Additional Plugin Option Overrides
|
||||||
|
#[derive(Debug, Default, PartialEq, Clone, Serialize, Deserialize)]
|
||||||
|
#[serde(tag = "type", rename = "options")]
|
||||||
|
#[serde(default)]
|
||||||
|
pub struct Options {
|
||||||
|
// base settings
|
||||||
|
theme: Option<String>,
|
||||||
|
// search settings
|
||||||
|
placeholder: Option<String>,
|
||||||
|
search_restrict: Option<String>,
|
||||||
|
search_min_length: Option<usize>,
|
||||||
|
search_max_length: Option<usize>,
|
||||||
|
// key settings
|
||||||
|
key_exec: Option<Vec<String>>,
|
||||||
|
key_exit: Option<Vec<String>>,
|
||||||
|
key_move_next: Option<Vec<String>>,
|
||||||
|
key_move_prev: Option<Vec<String>>,
|
||||||
|
key_open_menu: Option<Vec<String>>,
|
||||||
|
key_close_menu: Option<Vec<String>>,
|
||||||
|
// window settings
|
||||||
|
title: Option<String>,
|
||||||
|
deocorate: Option<bool>,
|
||||||
|
fullscreen: Option<bool>,
|
||||||
|
window_width: Option<usize>,
|
||||||
|
window_height: Option<usize>,
|
||||||
|
}
|
||||||
|
|
||||||
/// Retrieve EXE of Self
|
/// Retrieve EXE of Self
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn self_exe() -> String {
|
pub fn self_exe() -> String {
|
||||||
|
|
Loading…
Reference in a new issue