Introduction
CLiMAT, or Command Line Interface Macro Tree is a tool that streamlines working with command line interface tools. It can be used by both programmers and system administrators alike.
The core concept revolves around using a declarative approach to implement intuitive CLI interfaces.
Whether you want to create a new CLI tool, or you want a new CLI interface to an existing tool, CLiMAT can help you with that.
Example
Here is a brief example of what CLiMAT can do:
sgit {
sub acp(amend a: flag) {
action "git add . && git commit $(amend:--amend) && git push $(amend:--force)"
}
sub cf(branch: arg, force f: flag) {
action "git checkout feature/$(branch) $(force:--force)"
}
}
This simple script will create a toolchain (a CLI tool that has many capabilities) named sgit
with 2 subcommands:
acp
which will executegit add
,git commit
andgit push
. Takes an optional parameteramend
which will be passed on to thegit commit
as an--amend
flag, and to thegit push
as the--force
flag.cf
which will executegit checkout
, but the passed-in branch is always prefixed withfeature/
.
The generated tool can be used like this
sgit acp
sgit acp --amend
sgit acp -a
sgit cf myFeature
This is it. Now you have a git
macro that you can customize and tailor to your needs.
CLiMAT uses a special DSL (Domain-specific language) for its scripts that has many more capabilities than what is showcased in the above example. Learn more here.
Next, we're going to explore how to generate your first toolchain