Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion kbvm-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use {
generate::{self, GenerateArgs},
},
clap::{Args, Parser, Subcommand, ValueHint},
kbvm::xkb::ContextBuilder,
kbvm::xkb::{ContextBuilder, keymap::Formatter},
};

/// KBVM test utility.
Expand Down Expand Up @@ -44,6 +44,12 @@ pub struct CompileArgs {
/// Append an include path.
#[clap(long, value_hint = ValueHint::DirPath)]
pub append_include: Vec<String>,
/// Don't include key actions or behaviors.
#[clap(long)]
pub lookup_only: bool,
/// Rename long key names for compatibility with other XKB implementations.
#[clap(long)]
pub rename_long_names: bool,
}

impl CompileArgs {
Expand All @@ -58,6 +64,16 @@ impl CompileArgs {
builder.append_path(dir);
}
}

pub fn apply2<'a>(&self, mut formatter: Formatter<'a>) -> Formatter<'a> {
if self.lookup_only {
formatter = formatter.lookup_only(true);
}
if self.rename_long_names {
formatter = formatter.rename_long_keys(true);
}
formatter.multiple_actions_per_level(true)
}
}

pub fn main() {
Expand Down
2 changes: 1 addition & 1 deletion kbvm-cli/src/compile_rmlvo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ pub fn main(args: CompileRmlvoArgs) {
groups.as_deref(),
options.as_deref(),
);
format_keymap(expanded.format().multiple_actions_per_level(true));
format_keymap(args.compile_args.apply2(expanded.format()));
}
2 changes: 1 addition & 1 deletion kbvm-cli/src/compile_xkb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn main(args: CompileXkbArgs) {
let expanded = context.keymap_from_bytes(WriteToLog, Some(path.as_ref()), &source);
match expanded {
Ok(map) => {
format_keymap(map.format().multiple_actions_per_level(true));
format_keymap(args.compile_args.apply2(map.format()));
}
Err(_) => {
log::error!("could not compile keymap");
Expand Down