Hello World

Storytime

In 2017, I took a business trip to Santa Monica, CA. It was my first time working in the United States. I had a great time and learned a lot of new things, but what surprised me the most was the automation. There was a command-line interface (CLI) tool that automated developers' tasks.

This tool essentially checked if you had committed your changes, then ran unit tests, integration tests, checked coverage, scanned for vulnerabilities, and more. It was amazing. It had been built by some of the developers in Ruby.

Ruby wasn't part of the tech stack for any of our applications, but it was chosen because it comes preinstalled on macOS. This meant anyone with a Mac could run the tool right away. It also included other features that helped with project-specific tasks.

A few months later, I was back in my office, working for a different client with different technologies. In my day-to-day work, I often had to run several commands to get things done. I remembered that CLI tool. It could have optimized my workflow so that I could run one command instead of ten.

I decided to build something similar, but I was lazy. I didn't want to write a new CLI for each project, because that would mean building one again for the next project. So I thought: what if I could build a CLI at runtime from a JSON file?

This CLI would help me execute commands more efficiently. It would act as an auxiliary for (aux4) other tools.

On 6/29/2017, the first version of aux4 was published to npm. It was my private tool, there were no documentation. Just a CLI I could download and install from any machine, and automate my job.

How it works?

You can create a file .aux4 on a directory. The structure of the file is quite simple, it has an array of profiles (line 2), it will always look for the main profile (lines 3-16).

Each profile has a list of commands, in our example, we have only one command hello (lines 6-14). The command has an array of instructions that it will execute (lines 8-10). Those are regular CLI commands.

After some time, we always forget the things we made, so you can add some help information (lines 11-13).

{
  "profiles": [
    {
      "name": "main",
      "commands": [
        {
          "name": "hello",
          "execute": [
            "echo Hello World"
          ],
          "help": {
            "text": "Say Hello World"
          }
        }
      ]
    }
  ]
}

If you execute aux4 command in the same folder as the .aux4 file, it will display the list of commands available (from the main profile), and their documentation.

aux4
hello
Say Hello World.

To execute, you can go to the same folder, and call aux4 hello.

aux4 hello
Hello World

Why?

You may see this example as silly, but this is where it gets interesting.

aux4 turns a JSON file into a fully functional CLI. No compilation, no boilerplate, no framework to learn. You write a .aux4 file, and you have a CLI. Move to a new project? Write a new .aux4 file. Need to share it with your team? Commit the file. Need to chain multiple tools together? Add more commands.

Over the years, aux4 grew from a personal tool into an ecosystem. There are now packages for database operations, data transformation, encryption, API testing, and more — all composable through the same simple JSON structure.

The next posts will show you how to build real-world pipelines by combining these packages. Stay tuned.

See Also