Detects whether the CLI user was asking for help.

@param array $args
@return bool
482418
protected function _isHelpRequested($args) {
        if (array_key_exists('help', $args)) {
            return true;
        }

        if (!$this->_isFirstArgumentGiven($args)) {
            return false;
        }

        $helpWasAsked = strcasecmp($args[0], 'help') === 0;
        return $helpWasAsked;
    }
1283985
public function main(array $args = array()) {
        if ($this->_isHelpRequested($args)) {
            $this->_displayHelp();
            return true;
        }

        if (!$this->setArgs($args)) {
            return false;
        }
        $this->setFilter(new Garp_Cli_Command_Spawn_Filter($args));
        $this->setFeedback(new Garp_Cli_Command_Spawn_Feedback($args));
        $this->setModelSet($this->_initModelSet());

        $feedback = $this->getFeedback();
        $feedback->shouldSpawn() ? $this->_spawn() :
            $this->_showJsBaseModel($args[Garp_Cli_Command_Spawn_Feedback::JS_BASE_MODEL_COMMAND]);
        return true;
    }
607149
public function matchArgs($args)
    {
        if ($this->_args === null || $args === null) {
            return true;
        }
        $arg = $this->_classes['arg'];
        foreach ($this->_args as $expected) {
            $actual = array_shift($args);
            if ($expected instanceof $arg) {
                if (!$expected->match($actual)) {
                    return false;
                }
            } elseif ($actual !== $expected) {
                return false;
            }
        }
        return true;
    }
112096
public function handleDefine(Args $args)
    {
        $flags = $args->isOptionSet('force') ? DiscoveryManager::OVERRIDE : 0;
        $bindingParams = array();
        $paramDescriptions = array();

        $this->parseParamDescriptions($args, $paramDescriptions);
        $this->parseParams($args, $bindingParams);

        $this->discoveryManager->addRootTypeDescriptor(new BindingTypeDescriptor(
            new BindingType($args->getArgument('name'), $bindingParams),
            $args->getOption('description'),
            $paramDescriptions
        ), $flags);

        return 0;
    }
437474
public function execute(array $args = [], array $options = [])
    {
        /** @var CommandInterface[] $commands */
        $commands = $this->getConfig()->get('commands');

        $all = isset($options['all']) && true === $options['all'];

        $selectedCommands = [];
        foreach ($commands as $n => $c) {
            $hidden = false;
            $realName = $n;
            if ('_' === $n{0}) {
                if (!$all) {
                    continue;
                }
                $hidden = true;
                $n = substr($n, 1);
            }
            $selectedCommands[$n] = ['hidden' => $hidden, 'realName' => $realName, 'command' => $c];
        }

        ksort($selectedCommands);

        $user = $this->getConfig()->get('user_name');

        if ($user) {
            $this->writeln('<comment>DEV Console command</comment> (Happy hacking %s !)', $user);
        } else {
            $this->writeln('<comment>DEV Console command</comment>');
        }
        $this->writeln();
        $this->writeln('%d commands:', count($selectedCommands));

        $max = 0;

        foreach ($selectedCommands as $commandName => $def) {
            $len = strlen($commandName);
            $max = $max < $len ? $len : $max;
        }

        $lastLetter = null;

        foreach ($selectedCommands as $commandName => $def) {
            $letter = $commandName{0};
            if ($lastLetter !== $letter) {
                $this->writeln();
            }
            /** @var CommandInterface $command */
            $command = $def['command'];
            $command->setConfig($this->getConfig());
            $this->writeln("  <".($def['hidden'] ? 'comment' : 'info').">%-".$max."s</".($def['hidden'] ? 'comment' : 'info').">  <comment>%s</comment>", $commandName, $command->getDescription());
            $lastLetter = $letter;
        }

        $this->writeln();
    }
1241534
public function isEmpty(...$args): bool
    {
        if (!count($args)) {
            //test to see if it's empty
            return empty($this->data);
        }

        $separator = '--'. md5(uniqid()) . '--';

        $data = $this->getDot(implode($separator, $args), $separator);

        //if it's bool
        if (is_bool($data)) {
            //it's something
            return false;
        }

        //if it's scalar
        if (is_scalar($data)) {
            return !strlen($data);
        }

        return empty($data);
    }
317638
private function parseArgs(array $args) : string
    {
        if (!is_array($args)) return false;
        $components = array();
        if (count($args) == 1 && is_string($args[0])) {
            $components['src'] = $args[0];
            return $this->makeLink($components);
        } elseif (count($args) == 1 && is_array($args)) {
            $components = $args[0];
            return $this->makeLink($components);
        } elseif (count($args) == 2 && is_string($args[0]) && is_array($args[1])) {
            $args[1]['src'] = $args[0];
            $components = $args[1];
            return $this->makeLink($components);
        } elseif (count($args) == 2 && is_string($args[0]) && is_string($args[1])) {
            return '<script type="'.$args[1].'">'."\n".$args[0]."\n</script>\n";
        }
        Core::i()->log->warning('Unable to interpret script. Not added.');
        return false;
    }
1192562
public function handleRename(Args $args)
    {
        $moduleName = $args->getArgument('name');
        $newName = $args->getArgument('new-name');

        $this->moduleManager->renameModule($moduleName, $newName);

        return 0;
    }
1371595
private function checkCredentials(array $args = []): bool
    {
        if (empty($args['credentials'])) {
            throw new DorcasException('You did not provide the Dorcas client credentials in the configuration.', $args);
        }
        $id = data_get($args, 'credentials.id', null);
        $secret = data_get($args, 'credentials.secret', null);
        if (empty($id)) {
            throw new DorcasException('The client "id" key is absent in the credentials configuration.', $args);
        }
        if (empty($secret)) {
            throw new DorcasException('The client "secret" key is absent in the credentials configuration.', $args);
        }
        return true;
    }
1109805
public function helper($name, $args = [])
    {
        $args = func_get_args();
        $name = array_shift($args);
        if (isset($this->helpers[$name]) && is_callable($this->helpers[$name])) {
            return call_user_func_array($this->helpers[$name], $args);
        } elseif (($helper = [Helper::class, $name]) && is_callable($helper)) {
            return call_user_func_array($helper, $args);
        }

        throw new \RuntimeException(sprintf('undefined helper "%s" in %s line %d', $name, static::NAME, $this->getLineTrace()));
    }
1069943
private static boolean parseInputArgs(String[] args) {
    CommandLineParser parser = new BasicParser();
    CommandLine cmd;
    try {
      cmd = parser.parse(OPTIONS, args);
    } catch (ParseException e) {
      System.out.println("Failed to parse input args: " + e);
      return false;
    }
    sNoTimeout = cmd.hasOption("noTimeout");
    sHelp = cmd.hasOption("help");
    return true;
  }
122600
private function parseArgs($args) {
        $command = $action = null;
        $params = [];
        foreach ($args as $argument) {
            if ('-' != $argument[0])
                if (null === $command)
                    $command = $argument;
                elseif (null === $action)
                    $action = $argument;
                else
                    $this->alert('Invalid argument ' . $argument . '!', ['command' => $command, 'action' => $action, 'serverArguments' => $_SERVER['argv'], 'processedArguments' => $args]);
            else {
                $argument = substr($argument, 1); // supports both  one - or two - ( - / -- )
                if ('-' == $argument[0])
                    $argument = substr($argument, 1);

                $argument = explode('=', $argument, 2);
                $params[$argument[0]] = isset($argument[1]) ? $argument[1] : true;
            }
        }
        return [
            'command' => $command,
            'action' => $action,
            'params' => $params
        ];
    }
596994
public function help() {
        Garp_Cli::lineOut('Usage:');
        Garp_Cli::lineOut(' g Env setup', Garp_Cli::BLUE);
        Garp_Cli::lineOut('');
        Garp_Cli::lineOut('To enable under construction:');
        Garp_Cli::lineOut(' g Env setUnderConstruction', Garp_Cli::BLUE);
        Garp_Cli::lineOut('');
        Garp_Cli::lineOut('To disable under construction:');
        Garp_Cli::lineOut(' g Env setUnderConstruction false', Garp_Cli::BLUE);
        Garp_Cli::lineOut('');
        return true;
    }
1234549
public function process(...$args): bool
    {
        foreach ($this->registry as $callback) {
            if (call_user_func_array($callback, $args) === false) {
                return false;
            }
        }

        return true;
    }
553671
public function execute(array $argv = [])
    {
        if (empty($argv)) {
            return $this->help();
        }

        $cmd = array_shift($argv);
        if (isset($this->commands[$cmd])) {
            return $this->commands[$cmd]->initialize($argv, $this);
        }

        return $this->help($argv);
    }
1009574
private function _execute($args = array())
    {
        if ($this->_err) {
            return false;
        };
        if ($this->_sth) {
            if ($this->_sth->execute($args)) {
                return true;
            } else {
                $this->_err = implode(' ', $this->_sth->errorInfo());
                return false;
            };
        } else {
            $this->_err = "No statement to execute.";
        };
        return false;
    }
1087440
public function checkModelName(array $args)
    {
        $arg1 = self::getExprAttr($args[0], 'value', 'value');
        if ($arg1 && is_string($arg1)) {
            $model = ['path' => null, 'name' => $arg1];
            if ($pos = strrpos($arg1, '/')) {
                $model['path'] = substr($arg1, 0, $pos);
                $model['name'] = substr($arg1, $pos + 1);
            }
            $this->model_names[] = $model;
            return $model;
        }
    }