So I'm sure we've all spent time writing scripts or figuring out CLIs for that one project we're working on, and then kind of go on to forget what we did. Then, when another project comes along later, you wish you had that script again so you could see how you did that thing you did.
Personally, I used to just check random scripts into a repo as a kind of "archive" of all my scripts. But I wanted a better way to organize and use these things.
For years I've been building and collecting these scripts into a CLI that I call Devtools to make it so that each script is a subcommand.
I've had a lot of my friends and coworkers ask me to open-source it so they could use it and see how some things are done in Bash, what tools I use, etc. So...here's that CLI!
But what I'd honestly like is more...
So what are your useful scripts or CLIs you've built? Or what's that script you wrote years ago that you now swear by? Or what's that one application you use daily that just makes your life infinitely easier! I want to grow this collection and feed the addiction!
If you mean from my dotfiles, that's wild. A friend of mine wrote his own implementation in rust, but I've not really used their version, though I'm not sure its on github.
While I'm not currently using it, its on my todo list to take a real look at chezmoi for these per-machine differences; especially as I'm always between Linux, Windows & WSL. While chezmoi is outside the scope of this topic, it seems like a pretty solid configuration management option...and probably safer than what I'm doing (
ln -s).My "solution" is a collection of templates I'll load in to my editor (
nvim, with my ~~lackluster~~ plugin), which contains the basics for most scripts of a certain type. The only time that I'll write something and rely on something that isn't builtin, e.g. a customization, is if:require()the item & add testing for it[[ -z "${var}" ]], orcommand -vusuallyFor my work, every script is usually as "batteries included" as reasonable, in whatever language I'm required to work with (
bash,sh,pwshorgroovy). That said, the only items that appear in nearly every script at work are:main(),show_help(), etc.log()curlwrapper for Mailgun)Transpiling
bashintobashis probably the weirdest workflow I've ever heard of. While I can see some benefit of a "framework" mentality, if the 'compiled' result is a 30K line script, I'm not sure how useful it is IMO.For me at least, I view most shell scripts as being simple automation tools, and an exercise in limitation.
I did see some of that, even in the transpiled
dtoolsmonolithJust be aware that this reads the full contents into a variable, not an array. I would generally use
mapfile/readarrayfor multiline files. As for thejqexample, you should be able to get away withjq '.[]' < file.json, which is also POSIX when that's a concern.I don't think I'm the right person for that job -- I'm both unfamiliar with Ruby and have no desire to interract with it. I'm also pretty opinionated about shell generally, and likely not the right person to come up with a general spec for most people.
Additionally, my initial reaction that
bashlyseems like a solution in search of a problem, probably isn't healthy for the project.