Photo via Good Free Photos
Tomtit is a Perl6 task runner with dozens of plugins, you can use it as alternative for many task runners.
- it shapes best for Perl5/Perl6 developers as it written on Perl5/Perl6
- it has programmatic API for Perl6 language
- it has shortcuts for many common tasks - running Bash scripts, creation of files and starting/stoping services - https://github.com/melezhik/sparrowdo/blob/master/core-dsl.md
- it has dozens of plugins - http://sparrowhub.org - to solve more specific tasks
- it's extendible - you can take your favourite language and write a new plugin to address your specific needs.
As a bottom line it helps you to get things done with a minimal of fuss, yet not limited you to a static DSL but allow you to orchestrate your scenarios in modern and powerful language Perl6.
So, are you ready to get closer?
Tomtit is installed as Perl6 module.
zef install Tomtit
Once successfully installed Tomcat provides
tom - command line client to execute scenarios.
You'll need a system bootstrap to (*)install Tomtit's internal task runner, don't be afraid, it's one time operation.
(*) You'll need
sudo privileges to make bootstrap
Once you finish bootstrap you can execute scenario, let's take a look at typical tomtit workflow.
Your usual workflow with tomtit is when you define scenarios and then run them. It works especially nice with project-centric approach where you checkout the source code of application and run some related tasks.
Say, we have an application source code, where we perform 3 standard operations:
- and install
We end up with scenarios, we name then build, test and install.
make utility to build project, it could be just a 3 invocations of
make utility with related arguments.
Let's create our first Tomtit scenarios:
git checkout $git-repo mkdir .tom nano .tom/build.pl6 nano .tom/test.pl6 nano .tom/install.pl6
The code of every scenarios is as simple as running
bash "make test"
bash "sudo make install"
The tomtit scenarios are written in Perl6 and basically are just calls of different tasks, those scenarios however not necessarily limited tasks calls, they just are Perl6 programs where you can do anything you could with Perl6.
There are two syntactically different types of tasks in Tomtit. The first one you call by the means of
task-run function and second one is shortcuts - pretty much the same as
task-run but with mnemonic names and sometimes easier signatures.
In the scenarios for
make utility we used
bash shortcut to call a piece of Bash code. The full list of shortcuts as we as calling details is here - https://github.com/melezhik/sparrowdo/blob/master/core-dsl.md
In other words both task-run and shortcuts is just a way to call small piece if code that is downloaded from SparrowHub - script repository and then executed by
sparrow internal script runner for
tomtit, I have not told you but we have one more birds in our zoo-repository!
These small scripts or tasks are also called Sparrow plugins.
Tomtits scenarios basically are just a list of executed Sparrow plugins or tasks.
tom --list you'll see all the scenarios available now:
[scenarios list] build test install
Once scenarios are defined you run them through
tom --run=$scenario command.
And so on.
To recall what was the last scenario you run use
tom --last command.
You'll find thorough documentation on
tom command line client usage at Tomtit's gihtub pages.
Like I said, you are not limited running Bash only in Tomtit scenarios. You can run any task provided you find related plugin for it.
For example, let's create scenario that configure local git repository with user's parameters like username and email.
The task is often useful when you've just clone new project, make some changes and want to push some changes back to remote. Git requires you to set your identities as a commiter.
task-run "set git", "git-base", %( email => 'email@example.com', name => 'Alexey Melezhik', config_scope => 'local', set_credential_cache => 'on' );
By setting config_scope we ask task to make settings for local git repository and by setting set_credential_cache we also ask git to cache our password, so we don't enter it every time we do
The list of plugins you can use in Tomtit scenarios is available at SparrowHub - sparrow plugin repository.
In the next scenario example we create task to run VSTS build remotely through the vsts-build plugin:
task_run "run my build", "vsts-build", %( definition => "BackEndBuild" )
There are many other plugins you can use in Tomtit scenarios as tasks. Check out SparrowHub repository.
Tomtit provides you with the plenty of small script or plugins you might use in daily tasks, especially when dealing with source code management and build automation.
Tomtit scenarios are plain Perl6 scripts to generate dynamic lists of executed tasks - scripts with parameters.
There is syntax sugar - predefined set of built-in functions you can use instead of referring to plugins, that make code more concise and easier to read.
If for some reasons you don't find plugin to solve your task, you can always create your own one and start using it strait away.
Tomtit is easy to use, powerful and fun - give it a try, and let me know how it's going on.