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:
acpwhich will executegit add,git commitandgit push. Takes an optional parameteramendwhich will be passed on to thegit commitas an--amendflag, and to thegit pushas the--forceflag.cfwhich will executegit checkout, but the passed-in branch is always prefixed withfeature/.
The generated tool can be used like this
sgit acpsgit acp --amendsgit acp -asgit 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