CLI with Inquirer - 401-advanced-javascript-davetrost/alchemy-fsjs-fall-2019 GitHub Wiki

CLI with Inquirer

Reading Materials

CLI with Commander and Inquirer

  • Commander was used in this tutorial to review the command line arguments and assign an action to each of the valid options.
    • In addition, a description tag and an alias was added to each command line option. This enables a faster user experience and Commander will use the description field to automatically build a help output.
  • Commander can be used to parse rather flexible and potentially complex argument lists
    • example: .option('-s, --sugar [value]', 'Sugar level', "Low") // args.sugar = value, optional, default is 'Low'

Inquirer on GitHub

  • Inquirer.js strives to be an easy-to-embed and beautiful command line interface for Node.js
  • This makes it very good at:
    • providing error feedback
    • asking questions and parsing input
    • validating answers
    • managing hierarchical prompts
  • This makes it very bad at:
    • repeated action flows
      • for repeatable action flows, use Commander to build a command-line engine than can make repeated calls to Inquirer
  • There is a very helpful example script using Inquirer that walks through a pizza-ordering process