1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#[macro_use]
extern crate clap;
extern crate rs;

use rs::tests::check_layout_file;

fn main() -> () {
    #[cfg(feature = "clap_v4")]
    let matches = clap::Command::new("squeekboard-test-layout")
        .about("Test keyboard layout for errors. Returns OK or an error message containing further information.")
        .arg(
            clap::Arg::new("INPUT")
                .required(true)
                .help("Yaml keyboard layout file to test")
        )
        .get_matches();
    #[cfg(feature = "clap_v4")]
    let m = matches.get_one::<String>("INPUT");

    #[cfg(not(feature = "clap_v4"))]
    let matches = clap_app!(test_layout =>
        (name: "squeekboard-test-layout")
        (about: "Test keyboard layout for errors. Returns OK or an error message containing further information.")
        (@arg INPUT: +required "Yaml keyboard layout file to test")
    ).get_matches();
    #[cfg(not(feature = "clap_v4"))]
    let m = matches.value_of("INPUT");

    if check_layout_file(m.unwrap()) == () {
        println!("Test result: OK");
    }
}