src/Clapp/CommandLineArgumentDefinition.php
public function getUsage()
    {
        if (!$this->isParsed) {
            $this->parseDefinitions();
        } //if

        /* build list of argument names and calculate
           the first column width so we can pad to 
           align definitions */
        $firstCol = array();
        $longestDef = 0;
        foreach (array_keys($this->longNames) as $longName) {
            ob_start();
            echo "--{$longName}|-{$this->getShortName($longName)}";

            if ($this->allowsValue($longName)) {
                echo "={$this->getValueType($longName)}";
            } //if

            if ($this->allowsMultiple($longName)) {
                echo "+";
            } //if

            $defLength = ob_get_length();

            $longestDef = max($longestDef, $defLength);

            $firstCol[$longName] = ob_get_contents();
            ob_end_clean();

        } //foreach

        $firstColMaxWidth = $longestDef + 4;

        ob_start();

        foreach ($firstCol as $longName => $def) {
            $currentDefLength = strlen($def);

            $padding = str_repeat(" ", $firstColMaxWidth - $currentDefLength);

            echo "{$def}{$padding}{$this->getDescription($longName)}", PHP_EOL;
        } //foreach

        echo PHP_EOL;

        $usage = ob_get_contents();
        ob_end_clean();
        
        return $usage;

    }
public function getUsage()
    {
        if (!$this->isParsed) {
            $this->parseDefinitions();
        } //if

        /* build list of argument names and calculate
           the first column width so we can pad to 
           align definitions */
        $firstCol = array();
        $longestDef = 0;
        foreach (array_keys($this->longNames) as $longName) {
            ob_start();
            echo "--{$longName}|-{$this->getShortName($longName)}";

            if ($this->allowsValue($longName)) {
                echo "={$this->getValueType($longName)}";
            } //if

            if ($this->allowsMultiple($longName)) {
                echo "+";
            } //if

            $defLength = ob_get_length();

            $longestDef = max($longestDef, $defLength);

            $firstCol[$longName] = ob_get_contents();
            ob_end_clean();

        } //foreach

        $firstColMaxWidth = $longestDef + 4;

        ob_start();

        foreach ($firstCol as $longName => $def) {
            $currentDefLength = strlen($def);

            $padding = str_repeat(" ", $firstColMaxWidth - $currentDefLength);

            echo "{$def}{$padding}{$this->getDescription($longName)}", PHP_EOL;
        } //foreach

        echo PHP_EOL;

        $usage = ob_get_contents();
        ob_end_clean();
        
        return $usage;

    }
public function getUsage ( ) { if ( ! $ this -> isParsed ) { $ this -> parseDefinitions ( ) ; } //if /* build list of argument names and calculate
           the first column width so we can pad to 
           align definitions */ $ firstCol = array ( ) ; $ longestDef = 0 ; foreach ( array_keys ( $ this -> longNames ) as $ longName ) { ob_start ( ) ; echo "--{$longName}|-{$this->getShortName($longName)}" ; if ( $ this -> allowsValue ( $ longName ) ) { echo "={$this->getValueType($longName)}" ; } //if if ( $ this -> allowsMultiple ( $ longName ) ) { echo "+" ; } //if $ defLength = ob_get_length ( ) ; $ longestDef = max ( $ longestDef , $ defLength ) ; $ firstCol [ $ longName ] = ob_get_contents ( ) ; ob_end_clean ( ) ; } //foreach $ firstColMaxWidth = $ longestDef + 4 ; ob_start ( ) ; foreach ( $ firstCol as $ longName => $ def ) { $ currentDefLength = strlen ( $ def ) ; $ padding = str_repeat ( " " , $ firstColMaxWidth - $ currentDefLength ) ; echo "{$def}{$padding}{$this->getDescription($longName)}" , PHP_EOL ; } //foreach echo PHP_EOL ; $ usage = ob_get_contents ( ) ; ob_end_clean ( ) ; return $ usage ; }
builds a usage definition based on definition of params

@author Patrick Forget <patforg at webtrendi.com>
builds a usage definition based on definition of params