Parse Help

@param string $help

@return string
557026
public function help($help)
    {
        $green = "\033[49;32m";
        $end = "\033[0m";

        $array['import'] = [
            'Import Search Results',
            $green . 'mp3 import' . $end,
            '',
            'Option          Description             Required    Default    Available Options',
            '--confirm=      Display Confirmation    No          Yes        Yes, No'
        ];

        $implode = implode(
            "\n",
            $array[$help]
        );

        return $implode . "\n";
    }
1076115
public function parseString($string)
    {

        $stringHelper = $this->container->get('opifer.content.string_helper');

        $string = $stringHelper->replaceLinks($string);

        return $string;
    }
398783
def help_text(cls):
        """"""
        docs = [cmd_func.__doc__ for cmd_func in cls.commands.values()]

        # Don't want to include 'usage: ' or explanation.
        usage_lines = [doc.partition('\n')[0] for doc in docs]
        terse_lines = [line[len('Usage: '):] for line in usage_lines]
        terse_lines.sort()
        return '\n'.join(['Available commands:\n'] + terse_lines)
934688
protected function ask($question)
    {
        $helper = $this->getHelper('question');
        $question = new Question("<question>{$question}</question>");

        return $helper->ask($this->input, $this->output, $question);
    }
1013538
public function getHelp()
    {
        print Color::head('Help:') . PHP_EOL;
        print Color::colorize('  Lists the commands available in Console') . PHP_EOL . PHP_EOL;

        $this->run([]);
    }
1120424
protected function parse($strict = TRUE) {
        if(!$arguments = $this->flags->args()) {
            $message  = "Module not specified.\n";
            $message .= "\n";
            $message .= "To get help type:\n";
            $message .= "\n";
            $message .= "    {$this->command} ".implode(" ", array_merge($this->arguments, [ "help" ]));
            return $this->printError($message);
        }

        $module = array_shift($arguments);

        // check if we are in help mode
        $is_help = ($module == "help");

        if($is_help) {
            if(!$arguments) {
                $modules = [];
                if(class_exists("Loops\Application\LoopsAdmin\Cache")) $modules[] = "cache";
                if(class_exists("Loops\Application\LoopsAdmin\Jobs"))  $modules[] = "jobs";

                $message  = "Welcome to the Loops admin.\n";
                $message .= "\n";
                $message .= "You can run Loops internal commands via this interface.\n";
                $message .= "Loops internal commands are grouped into modules.\n";
                $message .= "\n";
                $message .= "Available (and known) modules:\n";
                $message .= "\n";
                $message .= $this->ident(implode(", ", $modules))."\n";
                $message .= "\n";
                $message .= "\n";
                $message .= "To get help about a module:\n";
                $message .= "\n";
                $message .= "    {$this->command} [<flags>...] help <module>\n";
                $message .= "\n";
                $message .= "Each module defines action(s) which are listed on the modules help page.\n";
                $message .= "\n";
                $message .= "\n";
                $message .= "To get help about an action:\n";
                $message .= "\n";
                $message .= "    {$this->command} [<flags>...] help <module> <action>\n";
                $message .= "\n";
                $message .= "\n";
                $message .= "Available flags:";
                return $this->printHelp($message);
            }

            // help for this module requested
            $module = array_shift($arguments);
        }

        $classname = "Loops\Application\LoopsAdmin\\".Misc::camelize($module);

        if(!class_exists($classname)) {
            return $this->printError("Module not found: $module");
        }

        $annotations = $this->getLoops()->getService("annotations")->get($classname);

        if(!$arguments) {
            if($is_help) {
                if(!$help = $annotations->findFirst("Admin\Help")) {
                    return $this->printError("Module '$module' does not define a help message.");
                }

                $actions = [];

                foreach($annotations->methods as $method => $method_annotations) {
                    if(!$method_annotations->findFirst("Admin\Action")) continue;
                    $actions[] = Misc::underscore($method);
                }

                $message  = "Help for module '$module':\n";
                $message .= "\n";
                $message .= $this->ident($help->help)."\n";
                $message .= "\n";
                $message .= "\n";
                $message .= "Available actions:\n";
                $message .= "\n";
                $message .= $this->ident($actions ? implode(", ", $actions) : "No actions defined.")."\n";
                $message .= "\n";
                $message .= "\n";
                $message .= "To get help about an action:\n";
                $message .= "\n";
                $message .= "    {$this->command} [<flags>...] help $module <action>\n";
                $message .= "\n";
                $message .= "\n";
                $message .= "Available flags:";
                return $this->printHelp($message);
            }
            else {
                return $this->printError("Action not specified for module '$module'.");
            }
        }

        $action = array_shift($arguments);
        $method = lcfirst(Misc::camelize($action));

        if(empty($annotations->methods->$method) || !$action_annotation = $annotations->methods->$method->findFirst("Admin\Action")) {
            return $this->printError("Module '$module' does not support action: $action");
        }

        $instance = new $classname($this->getLoops());

        if($action_annotation->init_flags) {
            if(!method_exists($instance, $action_annotation->init_flags)) {
                throw new Exception("Failed to init flags. Method '{$action_annotation->init}' is not defined.");
            }

            Misc::reflectionFunction([$instance, $action_annotation->init_flags], [$this->flags]);
        }

        if($is_help) {
            if(!$help = $annotations->methods->$method->findFirst("Admin\Help")) {
                return $this->printError("Action '$action' of module '$module' does not define a help message.");
            }

            $message  = "Usage:\n";
            $message .= "\n";
            $message .= "    {$this->command} [<flags>...] $module $action".($action_annotation->arguments ? " {$action_annotation->arguments}" : "")."\n";
            $message .= "\n";
            $message .= "\n";
            $message .= "Help for action '$module $action':\n";
            $message .= "\n";
            $message .= $this->ident($help->help)."\n";
            $message .= "\n";
            $message .= "\n";
            $message .= "Available flags:";
            return $this->printHelp($message);
        }

        try {
            $result = $this->flags->parse($this->arguments, !$strict, FALSE);
        }
        catch(Exception $e) {
            $message  = $e->getMessage()."\n";
            $message .= "\n";
            $message .= "To get help about this action:\n";
            $message .= "\n";
            $message .= "    {$this->command} help $module $action";
            return $this->printError($message);
        }

        $result = parent::parse();

        if(is_integer($result)) {
            $this->printError("test");
            return $result;
        }

        $result["__arguments"] = $arguments;
        $result["__module"]    = $module;
        $result["__action"]    = $action;

        $result["__instance"]  = $instance;
        $result["__method"]    = $method;

        return $result;
    }
662530
public function getProcessedHelp()
    {
        $name = $this->name;
        $isSingleCommand = $this->application && $this->application->isSingleCommand();

        $placeholders = [
            '%command.name%',
            '%command.full_name%',
        ];
        $replacements = [
            $name,
            $isSingleCommand ? $_SERVER['PHP_SELF'] : $_SERVER['PHP_SELF'].' '.$name,
        ];

        return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription());
    }
782668
protected function parse_format($format) {
		$format = parent::parse_format($format);
		return str_replace(array_keys(static::$months), static::$months, $format);
	}
76486
public function help()
    {
        $tf = new TableFormatter($this->colors);
        $text = '';

        $hascommands = (count($this->setup) > 1);
        foreach ($this->setup as $command => $config) {
            $hasopts = (bool)$this->setup[$command]['opts'];
            $hasargs = (bool)$this->setup[$command]['args'];

            // usage or command syntax line
            if (!$command) {
                $text .= $this->colors->wrap('USAGE:', Colors::C_BROWN);
                $text .= "\n";
                $text .= '   ' . $this->bin;
                $mv = 2;
            } else {
                $text .= "\n";
                $text .= $this->colors->wrap('   ' . $command, Colors::C_PURPLE);
                $mv = 4;
            }

            if ($hasopts) {
                $text .= ' ' . $this->colors->wrap('<OPTIONS>', Colors::C_GREEN);
            }

            if (!$command && $hascommands) {
                $text .= ' ' . $this->colors->wrap('<COMMAND> ...', Colors::C_PURPLE);
            }

            foreach ($this->setup[$command]['args'] as $arg) {
                $out = $this->colors->wrap('<' . $arg['name'] . '>', Colors::C_CYAN);

                if (!$arg['required']) {
                    $out = '[' . $out . ']';
                }
                $text .= ' ' . $out;
            }
            $text .= "\n";

            // usage or command intro
            if ($this->setup[$command]['help']) {
                $text .= "\n";
                $text .= $tf->format(
                    array($mv, '*'),
                    array('', $this->setup[$command]['help'] . "\n")
                );
            }

            // option description
            if ($hasopts) {
                if (!$command) {
                    $text .= "\n";
                    $text .= $this->colors->wrap('OPTIONS:', Colors::C_BROWN);
                }
                $text .= "\n";
                foreach ($this->setup[$command]['opts'] as $long => $opt) {

                    $name = '';
                    if ($opt['short']) {
                        $name .= '-' . $opt['short'];
                        if ($opt['needsarg']) {
                            $name .= ' <' . $opt['needsarg'] . '>';
                        }
                        $name .= ', ';
                    }
                    $name .= "--$long";
                    if ($opt['needsarg']) {
                        $name .= ' <' . $opt['needsarg'] . '>';
                    }

                    $text .= $tf->format(
                        array($mv, '30%', '*'),
                        array('', $name, $opt['help']),
                        array('', 'green', '')
                    );
                    $text .= "\n";
                }
            }

            // argument description
            if ($hasargs) {
                if (!$command) {
                    $text .= "\n";
                    $text .= $this->colors->wrap('ARGUMENTS:', Colors::C_BROWN);
                }
                $text .= "\n";
                foreach ($this->setup[$command]['args'] as $arg) {
                    $name = '<' . $arg['name'] . '>';

                    $text .= $tf->format(
                        array($mv, '30%', '*'),
                        array('', $name, $arg['help']),
                        array('', 'cyan', '')
                    );
                }
            }

            // head line and intro for following command documentation
            if (!$command && $hascommands) {
                $text .= "\n";
                $text .= $this->colors->wrap('COMMANDS:', Colors::C_BROWN);
                $text .= "\n";
                $text .= $tf->format(
                    array($mv, '*'),
                    array('', 'This tool accepts a command as first parameter as outlined below:')
                );
                $text .= "\n";
            }
        }

        return $text;
    }
1148382
private static function getHierPart(array $parsed)
    {
        return strlen($authority = self::getAuthority($parsed))
            ? '//'.$authority.$parsed['path']
            : $parsed['path'];
    }
218004
public function usageHelp()
    {
        $help = 'Available actions: ' . "\n";
        $methods = get_class_methods($this);
        foreach ($methods as $method) {
            if (substr($method, -6) == 'Action') {
                $help .= '    --action ' . substr($method, 0, -6);
                $helpMethod = $method . 'Help';
                if (method_exists($this, $helpMethod)) {
                    $help .= ' ' . $this->$helpMethod();
                }
                $help .= "\n";
            }
        }
        return $help;
    }
1145906
def parse_help_text(self, file_path):
        '''  '''
        with open(file_path) as f:
            lines = f.readlines()

        # Parse commands and descriptions, which are separated by a multi-space
        # (any sequence of two or more space characters in a row.
        cmds = []
        descs = []
        for line in lines:
            line = line.strip()
            if len(line) == 0:
                cmds.append('')
                descs.append('')
            else:
                tokens = line.split('  ')
                cmds.append(tokens[0])
                descs.append(''.join(tokens[1:]).strip())

        max_len = len(max(cmds, key=len))

        # Convert commands and descriptions into help text.
        text = ''
        for cmd, desc in zip(cmds, descs):
            if len(cmd) == 0:
                text += '\n'
            else:
                text += self.style.help(cmd.ljust(max_len + 2), desc + '\n')

        return cmds, text
790612
private function helpers()
    {
        $HELPERS_FILE = [];
        // From base
        if (file_exists($pathHelpers = VENDOR_KNOB_BASE_DIR . '/src/config/' . static::HELPERS_FILE . '.php')) {
            $HELPERS_FILE += include $pathHelpers;
        }
        // From App
        if (file_exists($pathHelpers = APP_DIR . '/config/' . static::HELPERS_FILE . '.php')) {
            $HELPERS_FILE += include $pathHelpers;
        }

        return array_merge([
            'case' => [
                'lower' => function ($value) {
                    return strtolower((string)$value);
                },
                'upper' => function ($value) {
                    return strtoupper((string)$value);
                },
            ],
            'count' => function ($value = []) {
                return count($value);
            },
            'moreThan1' => function ($value = []) {
                return count($value) > 1;
            },
            'date' => [
                'xmlschema' => function ($value) {
                    return date('c', strtotime($value));
                },
                'string' => function ($value) {
                    return date('l, d F Y', strtotime($value));
                },
                'format' => function ($value) {
                    return date(get_option('date_format'), strtotime($value));
                },
            ],
            'toArray' => function ($value) {
                return explode(',', $value);
            },
            'ucfirst' => function ($value) {
                return ucfirst($value);
            },
        ], $HELPERS_FILE);
    }
649258
public function getHelperName($key)
    {
        $helpers = $this->getOption('helpers', []);

        return is_array($helpers) && isset($helpers[$key])
            ? $helpers[$key]
            : $key;
    }
804910
protected function help()
    {
        
        
    	$usage = "Usage:php {$this->argv[0]} [arguments]\n";
    	$usage .= "\nArguments list:\n";
		foreach($this->inputFormat['parameters'] as $parameter){
		    $line = '';
       		if(isset($parameter['required'])){
       			if($parameter['required'] == true){
       				$line .= "Required";
       			}
       			else{
       				$line .= "Optional";
       			}
       		}
       		else{
       			//$usage .= "\t";
       		}
       		$line = str_pad($line, 15).' ';
			$line .= "--{$parameter['name']}";
       		if(isset($parameter['shortcut'])){
       			$line .= "|-{$parameter['shortcut']}";
       		}
       		$line = str_pad($line, 39).' ';
       		$line .= "{$parameter['description']}";
       		$usage .= $line."\n";
       	}
  		$this->out($usage, array('color' => 'light_blue'));
    	
        
    }
1356491
public function getHelp($key, array $args = array())
    {
        // Check if we can get a value, at all.
        if (empty($this->helpArray[$key]) === true) {
            return '';
        }

        // Return the value
        return vsprintf($this->helpArray[$key], $args);
    }
568709
public function help()
    {
        echo PHP_EOL;
        $output = new Output;
        $output->write('Available Commands', [
            'color'     => 'red',
            'bold'      => true,
            'underline' => true,
        ]);
        echo PHP_EOL;

        $maxlen = 0;
        foreach ($this->supportedArgs as $key => $description) {
            $len = strlen($key);
            if ($len > $maxlen) {
                $maxlen = $len;
            }

        }

        foreach ($this->supportedArgs as $key => $description) {
            $len = strlen($key);
            $output->write(' ')
                ->write($key, ['color' => 'yellow'])
                ->write(str_repeat(' ', $maxlen - $len))
                ->write(' - ')
                ->write($description);

            echo PHP_EOL;
        }

        echo PHP_EOL;

    }