Deploying upstream@dd1c58a0d1ff2004d7a9d6b4ed18f7b147c0046e: Clarify a point

This commit is contained in:
2026-01-19 17:13:01 -05:00
parent 4c9c66b3cd
commit 7a6d98c213
2 changed files with 3 additions and 3 deletions

View File

@@ -508,7 +508,7 @@
<li>You might need to accept an argument that defines a <code>key=value</code> pair, now you have to parse that pair, break it apart, and store them separately (depending on your use case)</li>
<li>You might need to accept multiple values for a given argument and build a list. How do you do this? Do you accept a string with space separated items? Do you accept the same argument over and over? How do you store this in your scripts internal state?</li>
</ul>
<p>I feel the same way about bash that I do about C: its basically the perfect language for gluing tasks together on a unix system. But this particular task in bash has always managed to really piss me off, because frankly, we can do so much better than what we are doing right now. This is one of the big reasons why people will abandon bash for the kinds of glue tasks its so good at, and move to something like <code>golang</code>, because theres not a great interface between the user and the script for configuring options at runtime. Parsing arguments can be downright unfriendly to the user, in fact, let alone to the developer. It doesnt have to be this way! Theres no reason why Java and Python and Ruby and Golang and <em>literally every other language out there</em> can have high quality argument parsing libraries but Bash cant have them.</p>
<p>I feel the same way about bash that I do about C: its basically the perfect language for its domain (in bashs case, gluing tasks together on a unix system). But this particular task in bash has always managed to really piss me off, because frankly, we can do so much better than what we are doing right now. This is one of the big reasons why people will abandon bash for the kinds of glue tasks its so good at, and move to something like <code>golang</code>, because theres not a great interface between the user and the script for configuring options at runtime. Parsing arguments can be downright unfriendly to the user, in fact, let alone to the developer. It doesnt have to be this way! Theres no reason why Java and Python and Ruby and Golang and <em>literally every other language out there</em> can have high quality argument parsing libraries but Bash cant have them.</p>
<p>So I wrote <a target="_blank" rel="noopener" href="https://github.com/akesterson/cmdarg">cmdarg</a>: A pure bash argument parsing library. This library solves all of the above problems you will suffer through in all of the above scenarios. Any time I need to add arguments to a bash script, I reach for this library, and I am always pleased with the result.</p>
<h2 id="Declarative-Syntax-for-Clear-Interfaces"><a href="#Declarative-Syntax-for-Clear-Interfaces" class="headerlink" title="Declarative Syntax for Clear Interfaces"></a>Declarative Syntax for Clear Interfaces</h2><p><a target="_blank" rel="noopener" href="https://github.com/akesteron/cmdarg">Cmdarg</a> wants to help you build a clear interface to your script without asking you to write any of the parsing code. You want to write your script - you dont want to write argument parsing code. So cmdarg allows you to <a target="_blank" rel="noopener" href="https://github.com/akesterson/cmdarg?tab=readme-ov-file#cmdarg-1">declare the interface</a>, <a target="_blank" rel="noopener" href="https://github.com/akesterson/cmdarg?tab=readme-ov-file#cmdarg_parse">parse the arguments</a>, and <a target="_blank" rel="noopener" href="https://github.com/akesterson/cmdarg?tab=readme-ov-file#tldr">get on with using the values in your script</a>. Cmdarg assumes your script will take 0 or more command line arguments, and each one of these arguments will have:</p>
<ul>

View File

@@ -6,7 +6,7 @@
<link href="https://aklabs.net/atom.xml" rel="self"/>
<link href="https://aklabs.net/"/>
<updated>2026-01-19T22:06:24.643Z</updated>
<updated>2026-01-19T22:12:47.060Z</updated>
<id>https://aklabs.net/</id>
<author>
@@ -21,7 +21,7 @@
<link href="https://aklabs.net/2026/01/19/This-Old-Tool-cmdarg/"/>
<id>https://aklabs.net/2026/01/19/This-Old-Tool-cmdarg/</id>
<published>2026-01-19T19:37:26.000Z</published>
<updated>2026-01-19T22:06:24.643Z</updated>
<updated>2026-01-19T22:12:47.060Z</updated>