Commands

  • tsargp -h print the help message
  • tsargp view the options' default values
  • tsargp ... play with option values
  • tsargp hello ... test the hello command
  • clear clear the screen
💡

You can select text from the terminal and paste it with Ctrl+V. Use the Up and Down arrow keys to navigate the history. For a full experience, you may want to try it locally instead: npm i -g tsargp && complete -C tsargp tsargp.

Things to try out

Word completion

  • check if completion works by pressing <Tab> (it behaves slightly differently than a real bash)
  • check if option names get completed (e.g., <Tab>, --<Tab>, --h<Tab>)
  • check if option parameters get completed (e.g., -b <Tab>, -se <Tab>, -ne=<Tab>)

Positional arguments

  • check if positional arguments can be specified before named ones (e.g., one -s 0)
  • check if all arguments after -- are recognized as positional (e.g., -- -f)

Cluster arguments

  • check if cluster arguments can be specified (e.g., -sn 1 -1)
  • check if cluster arguments can be specified with inline parameters (e.g., -s1 or -n-1)

Value constraints

  • check if a string parameter matches the required regex (e.g., try -s A and see that it fails)
  • check if a string parameter matches the required enums (e.g., try -se A and see that it fails)
  • check if a number parameter matches the required range (e.g., try -n 1 and see that it fails)
  • check if a number parameter matches the required enums (e.g., try -ne=0 and see that it fails)
  • check if the element count is limited to a certain amount (e.g., -- a b c d)

Value normalization

  • check if a string parameter gets normalized (e.g., -ss abc and see that it outputs ABC)
  • check if a number parameter gets normalized (e.g., -ns 1.7 and see that it outputs 2)
  • check if duplicate values get removed (e.g., --numbersUnique 1,2,1,2)

Value overwriting/appendage

  • check if values get overridden when a string option is specified repeatedly (e.g., -s 1 -s 2)
  • check if values get overridden when a number option is specified repeatedly (e.g., -n -1 -n -2)
  • check if values get overridden when an array option is specified repeatedly (e.g., one -- two)
  • check if values get appended when an array option is specified repeatedly (e.g., --numbersUnique 1 --numbersUnique 2)

Inline parameters

  • check if parameters can be inlined with option names (e.g., -ss=abc)
  • check if inline parameters can contain equal signs (e.g., -ss==a=b)
  • check if inline parameters are disallowed for an option (e.g., -se=one)
  • check if inline parameters are required for an option (e.g., -ne 1)

Help format and filters

  • check if the help option accepts option filters (e.g., -h -b -ne)
  • check if the help option accepts a help format (e.g., -h json)
  • check if the help option accepts a nested command name (e.g., -h hello)
  • check if the all of the above can be combined (e.g., -h hello json -h)

Miscellaneous

  • check if the -f option can be specified without a parameter, and negated with --no-flag
  • check if the -b option can be specified in combination with required options

Nested commands

💡

Press F12 to open the browser console and see the messages logged by the hello command.

  • check if the hello command works
  • check if the hello command can have its own options (e.g., hello -h)
    • in this help message, see that a positional option can have no name
  • check if the hello command can be specified recursively (e.g., hello a hello b c hello)

Text wrapping

With the browser console still open, slide the screen splitter leftwards until the terminal width changes, then run the help option and see if:

  • words in the option descriptions get wrapped correctly
  • words in the usage and footer get wrapped correctly

Toggle styles

  • check if styles can be omitted with NO_COLOR (e.g., NO_COLOR=1 ...)
  • check if styles are emitted with FORCE_COLOR (e.g., NO_COLOR=1 FORCE_COLOR=1 ...)
  • check if styles are emitted when resetting (e.g., NO_COLOR= FORCE_COLOR= ...)