jasonkuhrt / molt

⚡️ CLI building blocks & framework for the TypeScript era.
MIT License
76 stars 1 forks source link

better error message when required flag is missing #118

Open jasonkuhrt opened 1 year ago

jasonkuhrt commented 1 year ago

Perceived Problem

This is the feedback a user gets when they do not supply a required flag:

CleanShot 2023-01-15 at 20 58 37@2x

Problems:

Ideas / Proposed Solution(s)

Here is a monochrome sketch of better output:

CleanShot 2023-01-15 at 22 43 47@2x
jasonkuhrt commented 1 year ago

iteration two:

CleanShot 2023-01-22 at 17 04 04@2x
❯ px @molt/command run examples:intro

> @molt/command@0.6.0 examples:intro /Users/jasonkuhrt/projects/jasonkuhrt/molt/packages/@molt/command
> ts-node examples/intro.ts

┃ Oops! I could not execute command as you requested. There were some problems 
┃ with your input. See below for details.

                                INPUT ERRORS (x2)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
◌ MISSING INPUT                                                             (x2)

                                    1 ◌               2 ◌
                                    ┆                 ┆
            $ ts-node intro.ts   --filePath xxxx   --to xxxx

1 ◌ MISSING INPUT
--------------------------------------------------------------------------------
   You must give input for the "filePath" parameter. Here is its documentation:

   Name       Type/Description                       Default     Environment (1)                         
   filePath   string                                 REQUIRED    ✓          
              Path to the file to convert.                                          

2 ◌ MISSING INPUT
--------------------------------------------------------------------------------
   You must give input for the "to" parameter. Here is its documentation:

   Name       Type/Description                       Default     Environment (1)                         
   to         json | yaml | toml                     REQUIRED    ✓          
              Format to convert to.

NOTES
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
(1) Parameters can be passed arguments via environment variables. Command line                     
    arguments take precedence. Environment variable names are snake cased                          
    versions of the parameter name (or its aliases), case insensitive. They must                   
    be prefixed with CLI_PARAMETER_ or CLI_PARAM_ (case insensitive). Examples:                    
      → CLI_PARAMETER_MOVE="..."                                                                   
      → CLI_PARAMETER_VERBOSE="..."                                                                
      → CLI_PARAMETER_TO="...".