Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@keg-hub/ask-it

Package Overview
Dependencies
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@keg-hub/ask-it

Node CLI helper for asking questions

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
3
Weekly downloads
 
Created
Source

AskIt

Wrapper around inquirer to make asking questions in Node CLIs easier.

Setup

Install It

Add to your package.json

  "askIt": "git+https://github.com/keg-hub/askIt.git"

Use It

See an example here

;(() => {

  const { ask, separator, models } = require('askIt')

  // See src/models/models for more information
  const questionModelObject = {
    // Add the default input model
    ...models.input,
    // Override with custom values
    type: 'Question type',
    name: 'Name of the question',
    message: 'Question to ask',
    default: 'Default value if user enters nothing',
  }

  // Pass the model directly to the ask method
  // Returns a value entered by the user or the default
  const askResponse = await ask({ ...questionModelObject })

  // Ask a true / false question
  // Returns a boolean
  const confirmResponse = await ask.confirm('Ask a confirm question?')

  // Ask for text input
  // Returns a string of the entered text
  const inputResponse = await ask.input('Ask for text input')
  
  // Ask for a password / secret - input will be hidden
  // Returns a string of the entered text
  const passwordResponse = await ask.password('Ask for hidden text input')

  // Ask for user to select an option from a list of options
  // Returns the index of the select option within the passed in array
  const listResponse = await ask.promptList([
    'Option 1',
    'Option 2',
    'Option 3',
  ])

})()

API

ask

  • @type function
  • @param Object - a question model object
  • ask.confirm
    • @type function
    • @param string - The true / false question to ask
    • Helper method to ask a true/false question
    • Accepts a string used as the question asked to the user
  • ask.input
    • @type function
    • @param string - The text input question to ask
    • Helper method to ask a text input question
  • ask.password
    • @type function
    • @param string - The text input question to ask
    • Same as ask.input, except user input is hidden
  • ask.promptList
    • @type function
    • @param array - List of options to present to the user
    • Asks the user to select from a list of options
    • @returns - index of the selected item from the passed in options

separator

  • @type function
  • Helper that returns new inquirer.Separator()

models

  • @type Object
  • Prebuilt question models with defaults already set
  • Expected to be overwritten with custom values as needed
  • Question model object

FAQs

Package last updated on 05 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc