diff --git a/kbvm-cli/src/cli.rs b/kbvm-cli/src/cli.rs index 3ed474a..7a5825b 100644 --- a/kbvm-cli/src/cli.rs +++ b/kbvm-cli/src/cli.rs @@ -8,7 +8,7 @@ use { generate::{self, GenerateArgs}, }, clap::{Args, Parser, Subcommand, ValueHint}, - kbvm::xkb::ContextBuilder, + kbvm::xkb::{ContextBuilder, keymap::Formatter}, }; /// KBVM test utility. @@ -44,6 +44,12 @@ pub struct CompileArgs { /// Append an include path. #[clap(long, value_hint = ValueHint::DirPath)] pub append_include: Vec, + /// 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 { @@ -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() { diff --git a/kbvm-cli/src/compile_rmlvo.rs b/kbvm-cli/src/compile_rmlvo.rs index 15a20ae..2e504aa 100644 --- a/kbvm-cli/src/compile_rmlvo.rs +++ b/kbvm-cli/src/compile_rmlvo.rs @@ -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())); } diff --git a/kbvm-cli/src/compile_xkb.rs b/kbvm-cli/src/compile_xkb.rs index ea66e36..eef3753 100644 --- a/kbvm-cli/src/compile_xkb.rs +++ b/kbvm-cli/src/compile_xkb.rs @@ -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");