I was trying to visualise some S3 buckets for a cost optimisation exercise and wanted to be able to run a Tree command on it, obviously thats not a thing the Unix command can do … and I’ve been playing with JavaScript recently.
Earlier in the week I had used a tool which was installed from NPM as a global package, rather than defaulting to Python as I might usually have done I instead opted to do a bit of JavaScript which ive been trying to teach myself more of since the time it ruined Christmas and it funds my hobbies (please buy my wares)
So, off I went, pulled the arguments the Unix Tree command lists in the Man pages, removed the ones that where too complicated for me to think about and started writing code the features I ended up with can be boiled down in to 4 categories:
Python is my default language for things more anything more complicated than BASH, and I would usually use the argparse package. In JavaScript, yargs seems to be the alternative mostly because of the pirate themed icon. From there I just broke down what I needed and away I went; the recursion for building the object tree is still beyond my JavaScript skillz but not beyond ChatGPT & CoPilot.
I even wrote Unit tests! Jest seems way easier than Pytest to use, write, execute and debug.
It’s even got badges when the workflow runs - if that sort of thing on a new project doesn’t give you the warm-fuzzies, nothing will.