4 ms·
I write a Python script for this stuff. argparse with subparsers makes (fairly) light work of creating a command line tool with git-/svn-/etc.-style subcommands
by tom_ 2mo ago
I write a Python script for this stuff. argparse with subparsers makes (fairly) light work of creating a command line tool with git-/svn-/etc.-style subcommands, and you get very useful autogenerated --help output. (The fact you have to statically specify your program's command line interface up front is maybe a bit un-pythonic, but it's all the better for it.)
Python is always measurably more lines than the Makefile or shell script equivalent, but just think of the effect on your productivity metrics!
The standard shutil and subprocess modules are pretty convenient to use as-is. They're a bit syntactically tedious for anything that's a very basic sequence of shell operations, but in exchange you'll never forget to quote the arguments correctly. And I've always found that these processes to tend to grow over time anyway - something that's much easier to handle in Python! There's also far more scope for additional error checking and nicer UX.