Automating the Boring Stuff
Tags: python, programming, automation, productivity
Published: 2024-05-16 15:25:01

This is copy pasted from my [blog](https://0xff.nu) with added commentary below.

---

The idea for *boku* came from my dayjob, where we developed a robust onboarding script that takes care of setting up development environments for new onboardees.

While the onboarding script we use is robust and comfortable, it requires knowledge in Python to be able to add even the simplest of tasks to it. Moreover, each addition requires the binary to be recompiled and redistributed, so the portability and versatility of this tool suffers as a result.

*Boku* then comes to bridge this gap, yet is not intended to replace much more robust tools in order to keep it's simplicity.

The TL;DR is -

1. Was bored
2. Thought it might be useful because I personally need it
3. Learning experience \o/

---

The idea to automate things is doubtfully foreign to any of us, as we constantly seek better, more creative, more efficient ways of achieving certain results and completing certain tasks, while, if we're being honest, investing as little resources as possible.

```
~/d/onboarding master• ❱ pygount . --suffix py -f summary
┏━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━━━━┳━━━━━━┓
┃ Language      ┃ Files ┃     % ┃ Code ┃    % ┃ Comment ┃    % ┃
┡━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━╇━━━━━━╇━━━━━━━━━╇━━━━━━┩
│ Python        │    52 │  94.5 │ 3571 │ 54.7 │    1090 │ 16.7 │
│ __empty__     │     1 │   1.8 │    0 │  0.0 │       0 │  0.0 │
│ __duplicate__ │     2 │   3.6 │    0 │  0.0 │       0 │  0.0 │
├───────────────┼───────┼───────┼──────┼──────┼─────────┼──────┤
│ Sum           │    55 │ 100.0 │ 3571 │ 54.7 │    1090 │ 16.7 │
└───────────────┴───────┴───────┴──────┴──────┴─────────┴──────┘
```

It's easy to throw in overkill solutions (or money) at problems, and while the outcome will most likely be the same, the resources required or wasted (let alone the lack of any newly gained knowledge) will most likely offset the benefits.

These are the thoughts I had in mind while thinking about ways of improving the aforementioned onboarding script.
However, the ultimate decision for the onboarding script was to leave it as is complexity-wise, and improve it in other areas, but take the basic premise of developing a code-less solution for small tasks into a separate tool.

Just as an example, here's how a simple task could look like:
```YAML
version: 0.0.4
information: |
    Create a Mise config in the folder.
    Author: Paul Glushak (paul@glushak.net)
variables:
    config: |
        [tools]
        python = "latest"
        
        [env]
        _.python.venv = { path = ".venv", create = true }
tasks:
    create_config:
        run: |
            cat > .mise.toml << EOL
            variables.config
            EOL
    trust:
        run: mise trust
```

That is how TaskRunner™ was born! Yea, very original, I know. Worry not, now it's called *boku*.

The intention was, and is to keep the feature set simple, and make the tasks portable, hence the YAML files. This also allows *boku* to tie in to an existing workflow, or be run as a cronjob.

```
~/d/boku main• ❱ pygount . --suffix py -f summary
┏━━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━━━━┳━━━━━┓
┃ Language  ┃ Files ┃     % ┃ Code ┃    % ┃ Comment ┃   % ┃
┡━━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━╇━━━━━━╇━━━━━━━━━╇━━━━━┩
│ Python    │     4 │  80.0 │  473 │ 75.4 │      47 │ 7.5 │
│ __empty__ │     1 │  20.0 │    0 │  0.0 │       0 │ 0.0 │
├───────────┼───────┼───────┼──────┼──────┼─────────┼─────┤
│ Sum       │     5 │ 100.0 │  473 │ 75.4 │      47 │ 7.5 │
└───────────┴───────┴───────┴──────┴──────┴─────────┴─────┘
```

To conclude, as with other tools and things that I developed for personal use, I often find that a tailor-made brick can be 100% more effective than a generic, mass-produced spaceship (Wonderful analogy, I know!), depending on the situation of course.

Seek to improve, strive for efficiency and don't be afraid to make stuff for yourself and by yourself. Worst case - you're gonna learn something new.

---

Check out boku on [SourceHut](https://git.sr.ht/~hxii/boku).