No Code Argument Parsing for Command-Line Interfaces

What if you could only write the doc and use a single line of code to create your CLI?

Alexandre Couëdelo
CodeX

--

Photo by James Healy on Unsplash

When writing a command-line interface (CLI), you can save a lot of time and effort by using one of the dedicated libraries to parse arguments. Parsing all the arguments, writing the help message, and keeping the documentation in sync can be pretty time-consuming. What if you could only write the help message and use a single line of code to create your CLI? This is the deal that docopt offers you.

You know what’s awesome? It’s when the option parser is generated based on the beautiful help message that you write yourself! This way, you don’t need to write this stupid repeatable parser-code, and instead can write only the help message — the way you want it. (docotp author)

This library, in my opinion, stands out from its competitors:

  • docopt is available for many different languages: Python, Go, Rust, JAVA, Ruby, C, C++, PHP, and a few others.
  • Very little code to write.
  • You have to maintain the documentation. Those new arguments you want to have won’t be considered if you don’t update the help message.
  • This library doesn’t impose a convention on how to design the…

--

--

Alexandre Couëdelo
CodeX
Writer for

Software Supply Chain and Automation Specialist (aka. DevOps).