How to use suman-inquirer - 10 common examples

To help you get started, we’ve selected a few suman-inquirer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sumanjs / suman / lib / interactive / index.js View on Github external
function generateList(obj, onBackspace) {

    const dir = obj.firstAction;
    const root = path.resolve(__dirname + '/generate-command');
    const items = fs.readdirSync(root + '/' + dir);

    _interactiveDebug('ITEMS => ', items);

    return inquirer.prompt([
      {
        type: 'list',
        name: 'secondAction',
        message: 'What would you like to do?',
        onLeftKey: function () {
          _interactiveDebug('left key fired in generate list!');
          _suman.onBackspace(onBackspace);

        },
        default: 0,
        choices: items.map(function (item) {
          return String(item).slice(0, -3);  // get rid of ".js"
        }),
        when: function () {
          console.log('\n\n ----------------------------------------------------- \n\n');
          return true;
github sumanjs / suman / lib / interactive / index.js View on Github external
function start() {


    // process.stdin.removeAllListeners('keypress');
    // process.stdin.removeAllListeners('end');
    _interactiveDebug('readable count:', process.stdin.listenerCount('readable'));
    _interactiveDebug('keypress count:', process.stdin.listenerCount('keypress'));
    _interactiveDebug('keypress count:', process.stdin.listenerCount('keypress'));

    inquirer.restoreDefaultPrompts();

    inquirer.prompt(firstSetOfQuestions).then(function (respuestas) {
      if (respuestas.action === choices.topLevelOpts.GenerateCommand) {
        return secondSet(start);
      }
      else if (respuestas.action === choices.topLevelOpts.Learn) {
        throw new Error('Learn the Suman API is not implemented yet.');
      }
      else if (respuestas.action === choices.topLevelOpts.Troubleshoot) {
        throw new Error('Troubleshoot is not implemented yet.');
      }
      else {
        throw new Error('Action not recognized.');
      }

    }).catch(rejectionHandler);

  }
github sumanjs / suman / lib / interactive / index.js View on Github external
function start() {


    // process.stdin.removeAllListeners('keypress');
    // process.stdin.removeAllListeners('end');
    _interactiveDebug('readable count:', process.stdin.listenerCount('readable'));
    _interactiveDebug('keypress count:', process.stdin.listenerCount('keypress'));
    _interactiveDebug('keypress count:', process.stdin.listenerCount('keypress'));

    inquirer.restoreDefaultPrompts();

    inquirer.prompt(firstSetOfQuestions).then(function (respuestas) {
      if (respuestas.action === choices.topLevelOpts.GenerateCommand) {
        return secondSet(start);
      }
      else if (respuestas.action === choices.topLevelOpts.Learn) {
        throw new Error('Learn the Suman API is not implemented yet.');
      }
      else if (respuestas.action === choices.topLevelOpts.Troubleshoot) {
        throw new Error('Troubleshoot is not implemented yet.');
      }
      else {
        throw new Error('Action not recognized.');
      }

    }).catch(rejectionHandler);
github sumanjs / suman / test / src / exp / interactive / interactive.js View on Github external
const inquirer = require('suman-inquirer');
const util = require('util');

inquirer.prompt([
  {
    type: 'checkbox',
    message: 'Select any command line options (use spacebar)',
    name: 'command-line-options',

    choices: [
      {
        name: '--verbose, [type = arrayOfBool], (Verbose output. Use multiple times for more verbose.)',
        checked: true
      },
      {
        name: '--sparse, [type = bool], (Sparse output. Less verbose than standard.)',
        checked: true
      },
      {
        name: '--match-any, [type = arrayOfString], (Use this to filter input to match the given JS regex)',
github sumanjs / suman / lib / interactive / helpers / debug-single.js View on Github external
module.exports = function debugSingle (opts, backspaceCB) {

  const exec = opts.exec;

  return inquirer.prompt([
    {
      type: 'list',
      name: 'debugCmd',
      message: 'Which technique would you like to use to debug your tests?',
      onLeftKey: function () {
        _suman.onBackspace(backspaceCB);
      },
      when: function () {
        console.log('\n\n ----------------------------------------------- \n\n');
        return true;
      },
      choices: exec === 'node' ? choices.nodeDebug : choices.sumanDebug,
      filter: function (val) {
        return val;
      }
    },
github sumanjs / suman / lib / interactive / helpers / node-or-suman.js View on Github external
module.exports = function nodeOrSuman (opts, backspaceCB) {

  _suman.backspacing = false;
  const msg = opts.msg;

  return inquirer.prompt([
    {
      type: 'list',
      name: 'exec',
      onLeftKey: function () {
        _suman.onBackspace(backspaceCB);
      },
      message: msg || _implementationError('no message passed to fn'),
      when: function () {
        console.log('\n\n -------------------------------------------- \n\n');
        return true;
      },
      choices: choices.nodeOrSuman,
      filter: function (val) {
        console.log('\n\n');
        return val;
      }
github sumanjs / suman / lib / interactive / helpers / choose-dirs.js View on Github external
}
      else {
        throw new Error(' No option selected.');
      }

      if (answers.askAgain) {

        return ask(rootDir);

      } else {

        const $output = output.map(function (item) {
          return path.isAbsolute(item) ? item : path.resolve(rootDir + '/' + item);
        }).map((i, index) => ( (index + 1) + '  =>  "' + i + '"')).join(',\n');

        return inquirer.prompt([
          {
            type: 'confirm',
            name: 'confirmOutput',
            onLeftKey: function () {
              _suman.onBackspace(backspaceCB);
            },
            message: 'Are these the files/directories you wish to use? (To skip use the --fast option)\n\n' +
            colors.magenta($output) + '\n',
            when: function () {
              console.log('\n\n ----------------------------------------------- \n\n');
              _suman.backspacing = false;
              return true;
            },
            default: true
          }
        ]).then(function (respuestas) {
github sumanjs / suman / lib / interactive / helpers / local-or-global-suman.js View on Github external
assert(opts.exec, 'in localOrGlobal => "exec" property not defined.');

  if (opts.exec !== 'suman') {
    if (_suman.backspacing) {
      backspaceCB();
      return 'backspacing';
    }

    return Promise.resolve(Object.assign(opts, {
      localOrGlobal: null
    }));

  }

  return inquirer.prompt([

    {
      type: 'list',
      name: 'localOrGlobal',
      message: 'Want to use the global or locally installed Suman executable?',
      default: 0,
      choices: choices.localOrGlobalChoices,
      when: function () {
        if (opts.exec === 'suman') {
          console.log('\n\n --------------------------------- \n\n');
          _suman.backspacing = false;
          return true;
        }
        else if (_suman.backspacing) {
          backspaceCB();
        }
github sumanjs / suman / lib / interactive / helpers / available-options.js View on Github external
module.exports = function getAvailableOptions (opts, backspaceCB) {

  _interactiveDebug('opts in OPTIONS TO USE => ', opts);
  const optionsToUse = opts.optionsToUse;

  return inquirer.prompt([
    {
      type: 'checkbox',
      message: 'Select any command line options (use spacebar)',
      name: 'command-line-options',
      choices: optionsToUse,
      when: function () {
        console.log('\n\n ---------------------------------------- \n\n');
        _suman.backspacing = false;
        return true;
      },
      onLeftKey: function () {
        _suman.onBackspace(backspaceCB);
      },

      filter: function (vals) {
        return vals;
github sumanjs / suman / lib / interactive / helpers / watch-helper.js View on Github external
return true;
      },
      onLeftKey: function () {
        _suman.onBackspace(backspaceCB);
      },
      validate: function (item) {
        return true;
      }
    };
    prompt1.unshift(p);
    prompt2.unshift(p);
  }

  const z = keys.length < 1 ? prompt1 : prompt2;

  return inquirer.prompt(z).then(function (answers) {
    answers.mustInstallSumanServer = 'confirmNoSumanServerInstalled' in answers;
    answers.allowChoose = answers.useConfigWatchPresets !== 'yes';
    answers.watchProperty = answers.useConfigWatchPresets === 'yes' ? answers.watchPresetProperty : '';
    return Object.assign(obj, answers);
  });

};

suman-inquirer

A collection of common interactive command line user interfaces.

MIT
Latest version published 6 years ago

Package Health Score

60 / 100
Full package analysis