discover the functionality provided by the tool (see the section about a building a grammar).get information about the tool itself and its principles of operation.lookup all the information about verbs and arguments (see the next point about examples).It should be possible to use the CLI tool to: Don't spit out cryptic auto-generated argument lists, but leverage your CLI framework and TUI library to provide beautiful documentation. Instead of distributing the documentation as a separate wiki, make it part of your tool. Make documentation part of the tool itself A compromise is to make it an easily installable package through your languages package manager (pip, npm, what have you).Another option is to create a docker image that can be run with a single docker call, although this often makes networking and file IO more complicated.You can also experiment with dumping world images in Common Lisp. Golang and Rust are perfect languages for this, as they allow you to easily compile static binaries for multiple platforms.No one wants to install 80 node modules or god forbid, setup a python virtualenv, just to use your tool. To ensure widespread adoption of your CLI tool, it must be easily installable. Not only are these well established, they often allow you to use subcommands, generate autocompletion script for multiple shells, handle pretty-printing of CLI options and link up to configuration frameworks (see below).ĭistribute the tool as a single file with no dependencies While it is fun to parse argv by hand, I go straight for full-featured command-line parsing frameworks like cobra in go, clap in rust, Here are a collection of tips I gathered over the years writing CLI tools. You can now easily write scripts that exercise different functionality of your code while developing, create pre-commit scripts, create CICD scripts. I find command-line tools an incredibly way to multiply the impact of the code they produce.ĭid you write a nice library to wrap an API and connect it to your DB model? Then provide a CLI tool that allows anybody to query the API, interact with the DB model, run the operations that you provided, discover all the available functionality and read the API documentation.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |