February 19, 2019
I found myself on a project where, every time I wanted to sit down and do some work I had to type in a dozen weird little commands. Ngroking a tunnel, then ngroking another tunnel, then making sure my local builds piped to the right tunnels.
The commands that make this stuff happen are pretty ugly. It’s the type of robot nonsense the human mind is not meant to remember. I started by keeping them in a note, and just doing lots of copy-paste to the terminal.
It’s nice when that ugly stuff is wrapped up under a neat, tidy little command. (Yay create-react-app!) But what if you’re not so lucky to be working on a project loaded up with the hottest hotness?
You make your own! Which is what I did. I started with a wishlist:
Here’s what I ended up with. I can type one little command, and it shows me all the things I can do:
Just like a real CLI!
I started small, with serving the app locally and tunneling to connect to some external resources needed by the app. These were the some of the hairiest commands, so it was a huge boost to my sanity hide their weirdness behind a simple
Once I developed a nice pattern, it was easy to add more features — linting, going through a typical user journey, and all kinds of validation. (I’m still working on an automated accessiblity check.) I always run this before doing a push, just to make sure I didn’t break anything:
I built this using two great tools: Commander and ShellJS. I learned about Commander by poking through TJ’s Holowaychuk’s github. (I’ve found a bunch of great stuff lurking in the Githubs of good programmers.) Commander takes care of all the CLI boilerplate. It’s super easy to use. I had my initial version running in about ten minutes.
Maybe you’re thinking, Hey, shouldn’t this just be built in to the project? Why not put this stuff in the npm scripts? Shouldn’t the CI pipeline handle this stuff? Sure, that’d be nice, but sometimes you find yourself living in a less than ideal world. For all kinds of reasons, sometimes the tools you’re given aren’t the tools you want.
But you can just make your own! You don’t have to ask permission. You don’t even have to tell anyone. Don’t let old crusty tech stand in your way. You deserve to do awesome work, and you deserve great tools.