Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

inquirer-credentials

3.0.0 • Public • Published

inquirer-credentials

Build Status

Credentials prompt for CLI apps

Demonstration

Install

$ npm install inquirer-credentials --save

Usage

const inquirerCredentials = require('inquirer-credentials');
 
const username = {
  name: 'username',
  type: 'input',
  hint: 'please, tell your username',
  env: 'USERNAME' // uses process.env['USERNAME'] if exists and don't ask user
};
 
const password = {
  name: 'password',
  type: 'password',
  env: 'PASSWORD' // uses process.env['PASSWORD'] if exists and don't ask user
};
 
const creds = inquirerCredentials('.test');
 
creds
  .run([username, password])
  .then(function(result) {
    result.data //=> { username: 'string', password: 'string' }
    result.save() // persists config to fs, result is an instance of https://github.com/ewnd9/dot-file-config
 
    Object.keys(creds.config.data) //=> ['username', 'password']
  })
  .catch(function(err) {
    console.log(err.stack || err);
  });
 

Related

License

MIT © ewnd9

Install

npm i inquirer-credentials

DownloadsWeekly Downloads

2

Version

3.0.0

License

MIT

Last publish

Collaborators

  • avatar