/*
builds the process options

@param {obj} obj of process key and commands
@param {string} log root path
@param {obj} obj of command line options
@return {array} array of option objects
185497
function buildProcessOptions(processes, logRoot, cmdOptions) {
  return _.flatten(_.map(_.keys(processes), function(procKey) {
    var concurrentCount = parser.parseConcurrencyOpts(cmdOptions)[procKey] || 1;
    var command = processes[procKey];
    return _.map(_.range(concurrentCount), function(index) {
      return {
	port: cmdOptions.port,
	app: cmdOptions.app,
	appName: getProcessName(cmdOptions.app, procKey, index),
	environmentVar: getEnvOpts(command, cmdOptions),
	processCommand: command,
	processName: procKey,
	logRoot: logRoot,
	directory: parser.cmdWorkingDir(cmdOptions),
	user: cmdOptions.user,
	num: index
      };
    });
  }));
}
298663
def options(self, context, module_options):
        '''
        
        '''

        self.process = None

        if 'PROCESS' in module_options:
            self.process = module_options['PROCESS']
        else:
            context.log.error('PROCESS option is required')
            exit(1)

        self.share_name = gen_random_string(5).upper()
        self.ps_script1 = obfs_ps_script('cme_powershell_scripts/Invoke-PSInject.ps1')
        self.ps_script2 = obfs_ps_script('netripper/PowerShell/Invoke-NetRipper.ps1')

        context.log.info('This module will not exit until CTRL-C is pressed')
        context.log.info('Logs will be stored in ~/.cme/logs\n')

        self.smb_server = CMESMBServer(context.log, self.share_name, context.log_folder_path)
        self.smb_server.start()
1288391
def __get_logging_options(cmd_line_options, conf_file_options=None):
    
    options = {}

    for option in DEFAULT_OPTIONS['logging'].keys():
        options[option] = DEFAULT_OPTIONS['logging'][option]

        if conf_file_options and option in conf_file_options:
            options[option] = conf_file_options[option]

        if cmd_line_options and option in cmd_line_options:
            options[option] = cmd_line_options[option]

    return options
987673
function process(parent, index, commands) {
    var cmd = commands[index],
        ret;

    switch (cmd.value[0].type) {
        case ConkittyTypes.TEMPLATE_NAME:
            ret = processCall(parent, false, cmd);
            break;

        case ConkittyTypes.COMMAND_NAME:
            switch (cmd.value[0].value) {
                case 'ATTR':
                    ret = processAttr(parent, true, cmd);
                    break;

                case 'CALL':
                    ret = processCall(parent, true, cmd, commands[index + 1]);
                    break;

                case 'CHOOSE':
                    ret = processChoose(parent, cmd);
                    break;

                case 'EACH':
                    ret = processEach(parent, cmd, commands[index + 1]);
                    break;

                case 'EXPOSE':
                    ret = processExpose(parent, cmd);
                    break;

                case 'JS':
                    ret = processJS(parent, cmd);
                    break;

                case 'MEM':
                    ret = processMem(parent, cmd);
                    break;

                case 'PAYLOAD':
                    ret = processPayload(parent, cmd);
                    break;

                case 'SET':
                    ret = processSet(parent, cmd);
                    break;

                case 'TEST':
                    ret = processTest(parent, cmd);
                    break;

                case 'TRIGGER':
                    ret = processTrigger(parent, cmd);
                    break;

                case 'WITH':
                    ret = processWith(parent, cmd, commands[index + 1]);
                    break;

                default:
                    throw new ConkittyErrors.InconsistentCommand(cmd.value[0]);
            }

            break;

        case ConkittyTypes.VARIABLE:
            ret = processVariable(parent, cmd);
            break;

        case ConkittyTypes.JAVASCRIPT:
            ret = processJavascript(parent, cmd);
            break;

        case ConkittyTypes.STRING:
            ret = processString(parent, cmd);
            break;

        case ConkittyTypes.CSS:
            ret = processElement(parent, cmd);
            break;

        case ConkittyTypes.ATTR:
            ret = processAttr(parent, false, cmd);
            break;

        case ConkittyTypes.INCLUDE:
            ret = processInclude(parent, cmd);
            break;

        case ConkittyTypes.NODE_APPENDER:
            ret = processAppender(parent, cmd);
            break;

        default:
            throw new ConkittyErrors.InconsistentCommand(cmd.value[0]);
    }

    return index + ret;
}
947101
function ( options ) {
			this.protocol = options.protocol || 'http';
			this.port = options.port;
			this.server = options.server;
			this.path = options.path;
			this.proxy = options.proxy;
			this.jar = request.jar(); // create new cookie jar for each instance

			this.debug = options.debug;

			// set up logging
			const winston = require( 'winston' ),
				// file logging
				path = require( 'path' ),
				fs = require( 'fs' ),
				logDir = path.dirname( process.argv[ 1 ] ) + '/log/',
				logFile = logDir + path.basename( process.argv[ 1 ], '.js' ) + '.log',
				// how many tasks (i.e. requests) to run in parallel
				concurrency = options.concurrency || 3;

			this.logger = new ( winston.Logger )();

			// console logging
			if ( this.debug ) {
				this.logger.add( winston.transports.Console, {
					level: 'debug'
				} );
			}

			this.logger.cli();

			if ( fs.existsSync( logDir ) ) {
				this.logger.add( winston.transports.File, {
					colorize: true,
					filename: logFile,
					json: false,
					level: this.debug ? 'debug' : 'info'
				} );
			}

			// requests queue
			// @see https://github.com/caolan/async#queue
			this.queue = async.queue( function ( task, callback ) {
			// process the task (and call the provided callback once it's completed)
				task( callback );
			}, concurrency );

			// HTTP client
			this.formatUrl = require( 'url' ).format;

			this.userAgent = options.userAgent || ( `nodemw/${VERSION} (node.js ${process.version}; ${process.platform} ${process.arch})` );
			this.version = VERSION;

			// debug info
			this.info( process.argv.join( ' ' ) );
			this.info( this.userAgent );

			let port = this.port ? `:${this.port}` : '';

			this.info( `Using <${this.protocol}://${this.server}${port}${this.path}/api.php> as API entry point` );
			this.info( '----' );
		}
124703
function processArguments(props, args, defaults) {

    debug('processArguments',props,args,defaults);

    values = Object.assign({}, defaults);
    let properties = Object.getOwnPropertyNames(values);

    // First execute any single-arg functions to create dynamic defaults
    for (property of properties) {
        let value = values[property];
        if (typeof value === 'function' && value.length === 0) 
            values[property] = value();
    }

    // Then expand a single argument that is an object into a set of values
    if (args.length === 1 && typeof args[0] === 'object') {
        Object.assign(values, args[0]);
    } else {
    // Or assign arguments to properties in order
        for (i = 0; i < Math.min(args.length, props.length); i++)
            values[props[i]] = args[i];
    }

    debug('processArguments returns',values);
    return values;
}
935213
function logMethods (obj) {
  for (var key in obj) {
    if (obj.hasOwnProperty(key)) {
      if (key[0] !== '_' && !(key in EventEmitter.prototype) && typeof obj[key] === 'function' && !obj.logging) {
        obj[key] = logMethod(key, obj[key]);
      }
    }
  }
}
190840
function LogInterceptor($options, $callbackFn)
{
    if (arguments.length === 1)
    {
        if (_.isFunction(arguments[0]))
        {
            $options    = false;
            $callbackFn = arguments[0];
        }
        else if ($options === true)
        {
            $options = { 'passDown': true };
        }
        else if ($options === false)
        {
            $options = { 'passDown': false };
        }
    }
    else if (arguments.length >= 2 && !_.isFunction($callbackFn))
    {
        // when the 2nd arg is set but not a function, unset it
        $callbackFn = null;
    }

    // when options is not a valid object, use the default options
    var $extend = [{}, LogInterceptor._config];
    if ($options && _.isObject($options) && !_.isArray($options))
    {
        $extend.push($options);
    }

    $options = _.extend.apply(null, $extend);

    // load Level class when not already loaded. don't load at the top of this
    // file, otherwise the LogInterceptor referenced in level.js is empty
    if (!Level)
    {
        Level = require('./level.js');
    }

    // create new interceptor level
    var $level = new Level($options, $callbackFn);
    LogInterceptor._levels.push($level);

    // this is where the magic starts. replace the stdout write function with
    // an interceptor function wich allows us to capture the output from
    // `console.log` and process it anyway we like
    if (process.stdout.write !== LogInterceptor._interceptor)
    {
        process.stdout.write = LogInterceptor._interceptor;
    }
}
1253663
function _parseShellConfigOptions(argv) {
    var out = {};

    //`parse-pos-args` value is `true` by default, it must be
    //explicitly set to falsy value thus undefined & null values does not count
    if (argv['parse-pos-args'] === false || argv['parse-pos-args'] === 0) {
        setConfigPathOption(out);
        return out;
    }

    var options = argv.options.reduce(function(out, option, index) {
        if (index % 2 === 0) {
            out.names.push(option);
        } else {
            out.values.push(option);
        }
        return out;
    }, {
        names: [],
        values: []
    });

    if (argv.options.length % 2 !== 0) {
        throw new Error(
            `Invalid number of shell positional arguments received.
            Possitional arguments are expected to be in "[key] [value]" pairs`
        );
    }

    options.names.forEach(function(propPath, index) {
        _.set(
            out,
            propPath,
            json5.parse(options.values[index])
        );
    });

    setConfigPathOption(out);

    return out;

    function setConfigPathOption(obj) {
        //for overwriting expected config filepath we can use --config option only
        if (argv.config) {
            obj.fileConfigPath = argv.config;
            obj.fileConfigPath = path.normalize(obj.fileConfigPath);
        } else {
            delete obj.fileConfigPath;
        }
    }
}
539029
function registerUnknownCommands (cli, options) {
  cli.on('command:*', async () => {
    const { args, options: commandoptions } = cli

    logger.debug('global_options', options)
    logger.debug('cli_options', commandoptions)
    logger.debug('cli_args', args)

    const [commandName] = args
    const sourceDir = args[1] ? path.resolve(args[1]) : pwd
    const inferredUserDocsDirectory = await inferUserDocsDirectory(pwd)
    logger.developer('inferredUserDocsDirectory', inferredUserDocsDirectory)
    logger.developer('sourceDir', sourceDir)

    if (inferredUserDocsDirectory && sourceDir !== inferredUserDocsDirectory) {
      logUnknownCommand(cli)
      console.log()
      logger.tip(`Did you miss to specify the target docs dir? e.g. ${chalk.cyan(`vuepress ${commandName} [targetDir]`)}.`)
      logger.tip(`A custom command registered by a plugin requires VuePress to locate your site configuration like ${chalk.cyan('vuepress dev')} or ${chalk.cyan('vuepress build')}.`)
      console.log()
      process.exit(1)
    }

    if (!inferredUserDocsDirectory) {
      logUnknownCommand(cli)
      process.exit(1)
    }

    logger.debug('Custom command', chalk.cyan(commandName))
    CLI({
      async beforeParse (subCli) {
        const app = createApp({
          sourceDir: sourceDir,
          ...options,
          ...commandoptions
        })
        await app.process()
        app.pluginAPI.applySyncOption('extendCli', subCli, app)
        console.log()
      },
      async afterParse (subCli) {
        if (!subCli.matchedCommand) {
          logUnknownCommand(subCli)
          console.log()
        }
      }
    })
  })
}
299780
function processConsoleOptions(ctx) {
  var consoleOptions = ctx.opts.options;

  // If we are using Cordova 5.3.3 or lower - arguments are array of strings.
  // Will be removed after some time.
  if (consoleOptions instanceof Array) {
    return processConsoleOptions_cordova_53(consoleOptions);
  }

  // for newer version of Cordova - they are an object of properties
  return processConsoleOptions_cordova_54(consoleOptions);
}
798357
def shell(args=None, error=True):
    
    if args is None:
        args = sys.argv[1:]

    options = parse_options(args)
    setup_logger(options)
    LOGGER.info(options)

    # Install VSC hook
    if options.hook:
        from .hook import install_hook
        for path in options.paths:
            return install_hook(path)

    return process_paths(options, error=error)
899111
function optionBuilder(options) {
  options = options || {};

  var results = {stdin: [], args: [], files: []};
  Object.keys(options).map(function (option) {
    var p4option = p4options[option];
    if (!p4option) return;
    if (p4option.category !== 'unary') {
      if ((options[option] || {}).constructor !== p4option.type) return;
    }
    if (p4option.category === 'stdin') {
      results.stdin.push(p4option.cmd + options[option]);
      if (results.args.indexOf('-i') < 0) results.args.push('-i');
    } else if (p4option.cmd) {
      results.args.push(p4option.cmd);
      if (p4option.category === 'mixed') results.args.push(options[option]);
    } else {
      results.files = results.files.concat(options[option]);
    }
  });
  return results;
}
202429
function processExecCommand (obj) {
        console.assert(obj);
        try {
          if (obj.type === TNMT$1.AddExecCommandQueueSuccess) {
            __agent.log(logCord$7, 'add exec command queue success and start after!');
            var queueID = obj.queueInfo.id;
            $bc_$16.sendQueueEvent(queueID, 'execcommand', 'start');
            __mc.trigger(TypeMsg$6.onExecCommandAdded, {
              data: obj
            });
          } else if (obj.type === TNMT$1.ExecCommandStart) {
            __agent.log(logCord$7, 'exec command start ...');
            __mc.trigger(TypeMsg$6.onExecCommandStarted, {
              data: obj
            });
          } else if (obj.type === TNMT$1.ExecCommandReportProgress) {
            __agent.log(logCord$7, 'report exec command progress ...');
            __mc.trigger(TypeMsg$6.onExecCommandFeedback, {
              data: obj
            });
          } else if (obj.type === TNMT$1.ExecCommandSuccess) {
            __agent.log(logCord$7, 'exec command success ...');
            __mc.trigger(TypeMsg$6.onExecCommandSuccess, {
              data: obj
            });
          } else if (obj.type === TNMT$1.CancelExecCommand) {
            __agent.log(logCord$7, 'exec command cancel ...');
            __mc.trigger(TypeMsg$6.onExecCommandCanceled, {
              data: obj
            });
          } else if (obj.type === TNMT$1.ExecCommandFailed) {
            __agent.log(logCord$7, 'exec command error ...');
            __mc.trigger(TypeMsg$6.onExecCommandError, {
              data: obj
            });
          }
        } catch (error) {
          console.error(logCord$7, error);
        }
      }
1088917
function createLogger(name, options) {
        var log = typeof debug === 'undefined' ? _debug(name) : debug(name),
            level,
            levels = {
                silly: 0,
                input: 1,
                verbose: 2,
                prompt: 3,
                debug: 4,
                info: 5,
                data: 6,
                help: 7,
                warn: 8,
                error: 9
            };
        if (!options) {
            throw new Error('options required in logger');
        }
        if (options.hasOwnProperty('level') === false) {
            throw new Error('options.level required in logger');
        }
        level = levels[options.level];
        if (typeof level === 'undefined') {
            level = levels.info;
        }

        log.debug = function () {
            if (log.enabled && level <= levels.debug) {
                if (console.debug) {
                    log.log = console.debug.bind(console);
                } else {
                    log.log = console.log.bind(console);
                }
                log.apply(this, arguments);
            }
        };
        log.info = function () {
            if (log.enabled && level <= levels.info) {
                log.log = console.info.bind(console);
                log.apply(this, arguments);
            }
        };
        log.warn = function () {
            if (log.enabled && level <= levels.warn) {
                log.log = console.warn.bind(console);
                log.apply(this, arguments);
            }
        };
        log.error = function () {
            if (log.enabled && level <= levels.error) {
                log.log = console.error.bind(console);
                log.apply(this, arguments);
            } else {
                console.error.apply(console, arguments);
            }
        };

        log.fork = function (forkName, useForkName) {
            forkName = useForkName ? forkName : name + ':' + forkName;
            return createLogger(forkName, options);
        };

        log.forkWithOptions = function (_name, _options) {
            return createLogger(_name, _options);
        };

        return log;
    }
711611
function createOptions( options ) {
    var object = optionsCache[ options ] = {};
    _each( options.split( /\s+/ ), function( flag ) {
      object[ flag ] = true;
    });
    return object;
  }
611792
function buildLogRunTemplate(opts, callback) {
  var viewOpt = {
    logRoot: opts.cmdOptions.log || ('/var/log/' + opts.cmdOptions.app),
    processName: opts.procName,
    num: opts.index,
    user: opts.cmdOptions.user
  };

  renderTemplate(templateFilePath('log_run', opts.templateOpt), viewOpt, function(err, renderedOutput) {
    if (err) {
      return callback(err.message);
    } else {
      return fs.writeFile(opts.processLogRunPath, renderedOutput, function(err) {
	if (err) {
	  return callback(err.message);
	} else {
	  fs.chmodSync(opts.processLogRunPath, 0755);
	  return callback(null);
	}
      });
    }
  });
}