How to use the private/optparse.OptionParser function in private

To help you get started, we’ve selected a few private 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 seedjs / seed / lib / commands.js View on Github external
Cmds.commands(function(err, commands) {
    if (err) return done(err);
    var packageId = commands[cmd.toLowerCase()], exports;
    if (packageId) {
      try {
        exports = require(packageId);
      } catch(e) {
        exports = null;
      }
    }

    var opts = new optparse.OptionParser(STD_SWITCHES);
    
    if (!exports || !exports.invoke) {
      return Cmds.unknown(cmd, args, opts, done);
    } else {
      // ok try to parse the options and see if we need to do help
      var showHelp = false;
      opts.on('help', function() { showHelp = true; });
      opts.on('verbose', function() { require.env.VERBOSE = true; });
      opts.parse(args);
      if (showHelp) {
        return help.invoke(cmd, [cmd], opts, done);
      } else {
        opts = (exports.options || []).slice();
        opts = opts.concat(STD_SWITCHES);
        opts = new optparse.OptionParser(opts); 
        return exports.invoke(cmd, args, opts, done);
github seedjs / seed / lib / commands.js View on Github external
var opts = new optparse.OptionParser(STD_SWITCHES);
    
    if (!exports || !exports.invoke) {
      return Cmds.unknown(cmd, args, opts, done);
    } else {
      // ok try to parse the options and see if we need to do help
      var showHelp = false;
      opts.on('help', function() { showHelp = true; });
      opts.on('verbose', function() { require.env.VERBOSE = true; });
      opts.parse(args);
      if (showHelp) {
        return help.invoke(cmd, [cmd], opts, done);
      } else {
        opts = (exports.options || []).slice();
        opts = opts.concat(STD_SWITCHES);
        opts = new optparse.OptionParser(opts); 
        return exports.invoke(cmd, args, opts, done);
      }
    }
  });
};
github seedjs / seed / lib / commands / help.js View on Github external
var packageId = commands[cmd], exports;
    
    try {
      exports = require(packageId);
    } catch(e) {
      exports = null;
    }
        
    if (!exports || !exports.invoke) {
      CORE.println("Unknown command " + cmd);
      return done();
    }

    var opts = (exports.options || []).slice();
    opts = opts.concat(Cmds.STD_SWITCHES);
    opts = new optparse.OptionParser(opts);
    opts.banner = 'usage: seed ' + (exports.usage || cmd);
    CORE.println(opts.toString());
    if (exports.desc) CORE.println('\n' + exports.desc + '\n');
    return done();
  });
}