denoland / denoland/std

std/flags should be able to provide "--help" usage information

Open
#1,586 11 comments 5 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
TypeScript
Stars
3.6k
Forks
681
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**

Deno's std/flags module can parse command line arguments, but a complete command line interface should also be self-documenting, e.g. by printing out usage information when "--help" is specified. Currently, there doesn't appear to be anything in the standard library for producing usage information.

**Describe the solution you'd like**

My personal preference would be to extend the existing std/flags module to support *optionally* generating usage information on "--help". I created a prototype module here: [x/flags_usage](https://deno.land/x/flags_usage@1.0.0) (note: I'm not claiming this is the ideal solution; it just does what I want and has reasonable default behavior on the interfaces I've tested it on).

**Describe alternatives you've considered**

* Manually printing out usage
* Obviously can be done today, but it would be nice if the standard library made this easy to do (at least for trivial cases such as tools that only have string/bool/number options), so that we'd all spend less time formatting strings, and tools would have a more consistent style
* Third party modules
* There are some third party modules for this (in the Node ecosystem, I liked [commander](https://www.npmjs.com/package/commander)), but I think it would make sense to just build on the existing std/flags module because it seems to be widely used (and again, there would be more consistency)
* Leaving this to third party modules is reasonable, but not ideal, in my opinion
* Focus only on parsing and leave usage out of the picture, i.e. do nothing
* This is what [minimist](https://www.npmjs.com/package/minimist) did ([relevant issue](https://github.com/substack/minimist/issues/90))
* I think the same reasoning does not apply here because Deno claims to be convenient for creating command line utilities ("Deno is a great replacement for utility scripts that may have been historically written with Bash or Python.") and having usable command line interfaces is required for that, so creating such interfaces should be easy

Contributor guide

Open the contributing guide

Research direction

Start by reading the std/flags module and comparing its current interfaces with the linked flags_usage prototype. The scope still needs an agreed API and behavior for optional --help usage generation; done means that design is implemented and its output and supported option types are verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.