So, you have a lot of scripts you want to port to other server or share with your team.

While straightforward git push, git pull approach works well, you still have things to care about:

Setting up scripts input parameters

Installing scripts dependencies

Generating scripts documentation

Scripts versioning

With Sparrow - scripts management platform written in Perl - all those tasks could be done with minimal fuss.

Develop scripts

As Sparrow for today supports many languages, you are almost not limited, choose the one you want:

Perl

Ruby

Python

Bash

Powershell

Both Windows and Linux platforms are supported.

For simplicity reasons I will show you an example for Bash:

cat $story.bash



echo "hello world"

Defining default values for input parameters.

It's easy. Just create configuration called suite.yaml to define deafult configuration data:

cat suite.yaml



name: Sparrow

Then adjust the script to read the configuration file:



echo "hello world, my name is " $( config name )

Defining script metadata

We will use metadata to install scripts across different servers and into local system, we can define many attributes here in metadata file, meanwhile it's just a script name:

cat sparrow.json



{ "name" : "hello-world" }

Testing script

Install it locally:

sparrow plg install . --local



sparrow root: [/root/sparrow] install from source: /root/projects/dev.to/plugins ... install public@hello-world version 0 from local source install deps for /root/sparrow/plugins/public/hello-world ...

And run it:

sparrow plg run hello-world



sparrow root: [/root/sparrow] plugin is not listed in the index, locally installed one? at /usr/local/share/perl5/Sparrow/Commands/Plugin.pm line 415. 2018-11-20 08:53:57 : [plg] hello-world [path] / hello world, my name is Sparrow ok scenario succeeded STATUS SUCCEED

Adding documentation

It's simple, just create README.md file having documentation in markdown format:

cat README.md



# Description This is hello-world script # Usage sparrow plg run hello-world # Parameters ## Name # Author Alexey Melezhik

Let's reinstall script, to add documentation bit:

sparrow plg install . --local --force

Now we can see script's documentation:

sparrow plg man hello-world

Overriding default values for configuration file

It's just a little extra step, we need to create sparrow task to run the script:

sparrow project create birds

sparrow task add birds crow hello-world



project birds successfully created task - set plugin to public@hello-world task birds/crow successfully created

sparrow task ini birds/crow



name: Crow

The task we've just created overrides default values for hello-world script, let's run it:

sparrow task run birds/crow



sparrow root: [/root/sparrow] 2018-11-20 09:08:50 : [task] crow [path] / hello world, my name is crow ok scenario succeeded STATUS SUCCEED

Save script and configuration data

It's just one simple command and push all the data to git repository:

cd ../ && sparrow task save $PWD



sparrow root: [/root/sparrow] read task ignore file from /root/task.ignore ... save current tasks to [/root/projects/dev.to] ... ========================= birds/crow ...

git add . && git commit -a -m "my cool scripts" && git push

Distributing scripts

On target server just git clone scripts repository:

git clone $git-repo.tasks ~/scripts-repo

And then run:

sparrow plg install ~/scripts-repo/plugins --local --recursive



sparrow root: [/root/sparrow] install from source: /root/scripts-repo/plugins ... install public@hello-world version 0 from local source install deps for /root/sparrow/plugins/public/hello-world ...

sparrow task restore ~/scripts-repo



sparrow root: [/root/sparrow] restore tasks from [/root/scripts/repo] ... ========================= restore birds/crow ... plugin /root/sparrow/plugins/public/hello-world/ installed locally, nothing to do here ...

Now you have all you scripts up and running on new server:

sparrow task run birds/crow

Further reading

Handling dependencies

It's dead easy. Sparrow supports many popular package managers ( cpan, rubygems, pip ), just place proper dependency file to your script's folder ( cpanfile, Gemfile, requirements.txt )

Scripts versioning

Just bump script's version inside metafile to let users install and use the latest version:



{ "name" : "hello-world" , "version" : "0.1.1" }

Thank you for reading.