kalamine
kalamine copied to clipboard
Command-line interface
Usage
kalamine -in [format]:[file] -out [format]:[file]
Formats
Input
yaml: YAML
Output
xkb: XKB for Linuxkeylayout: Keyboard Layouts for Macklc: KLC for Windows
Files
Input
-: Refers to standard input
Output
-: Refers to standard output
Examples
Simple
kalamine -in qwerty.yml -out qwerty.xkb
# qwerty.xkb
kalamine -in qwerty.yml -out xkb:
# qwerty.xkb
Multiple outputs
kalamine -in qwerty.yml -out qwerty.{xkb,keylayout,klc}
# qwerty.xkb
# qwerty.keylayout
# qwerty.klc
kalamine -in qwerty.yml -out {xkb,keylayout,klc}:
# qwerty.xkb
# qwerty.keylayout
# qwerty.klc
Multiple inputs and outputs
kalamine \
-in qwerty.yml -out qwerty.xkb \
-in azerty.yml -out azerty.xkb
# qwerty.xkb
# azerty.xkb
kalamine \
-in qwerty.yml -out xkb: \
-in azerty.yml -out xkb:
# qwerty.xkb
# azerty.xkb
Read and write from and to standard streams
kalamine -in yaml:/dev/stdin -out xkb:/dev/stdout < qwerty.yml
# /dev/stdout
kalamine -in yaml:- -out xkb:- < qwerty.yml
# <stdout>
kalamine -in yaml:- -out xkb: < qwerty.yml
# <stdout>
I’ve just pushed a patch to use click as the command-line parser, see commit https://github.com/fabi1cazenave/kalamine/commit/a229ee81cc925f9d3a79596355c423a50a1b25d7. Click looks promising but we’re not done yet — far from it.
Click nicely handles multiple values for an argument with the nargs=-1 trick, but there’s no easy way to handle multiple values for an option (though there are some workarounds). So for now, instead of using -in and -out, Kalamine uses an argument for the input and a single value for the output — and in fact, this suits all my use cases so far. Here are a couple examples of what works yet:
kalamine qwerty.yaml --out xkb
# qwerty.xkb
kalamine qwerty.yaml --out dist/lafayette.xkb
# dist/lafayette.xkb
kalamine qwerty42/fr.yaml --extends qwerty42.yaml --out all
# dist/qwerty42.keylayout
# dist/qwerty42.klc
# dist/qwerty42.xkb
# dist/xkb/fr/qwerty42
kalamine qwerty42/* --extends qwerty42.yaml --out klc
# qwerty42/de.klc
# qwerty42/es.klc
# qwerty42/fr.klc
# qwerty42/it.klc
(Note: --out all is assumed by default, which is ugly… but handy in the short-term for the forward compatibility.)
Feedback is welcome.
Patches are welcome as well, especially to handle standard streams.
I’d happily merge a patch for the --out qwerty.{xkb,keylayout,klc} trick, too. :-)
Shouldn’t this issue be closed ?