Hello all.

Just getting back into the docs and I'm coming up against the changes made
in
http://git.php.net/?p=phd.git;a=commitdiff;h=dc61fff7daab9c3498f5c4bd8ddee9fbea139989;hp=e65c062692173f921c16a1bc81f2d70e60a253a4

>From what I am seeing, to use optional values (lang::), I need to use the =
separator (this may be windows only and a bug - I'm not sure).

So, --lang=en rather than --lang en

But the patch gives an error ...

[02:28:41 - E_USER_ERROR          ]
D:\PHP\Manual\PHD\phpdotnet\phd\Options\Parser.php:84
        Invalid long option --lang=en

So, adding some debugging (print_r()'s on $args), and using a command line
like ...

D:\PHP\Manual\phd\render --package PHP --format enhancedchm --docbook
D:\PHP\Manual\PHP\doc-all\doc-base\.manual_en.xml --lang en --output
D:\PHP\Manual\rendering\PHP\en --color true --css reset.css --css theme.css
--css doc.css --saveconfig true

I get output of ...

array(4) {
  ["package"]=>
  string(3) "PHP"
  ["format"]=>
  string(11) "enhancedchm"
  ["docbook"]=>
  string(49) "D:\PHP\Manual\PHP\doc-all\doc-base\.manual_en.xml"
  ["lang"]=>
  bool(false)
}

Which is fine, upto lang. No '=' and things bomb out.

Without the checkOptions() call, and using a command line like ...

D:\PHP\Manual\phd\render --package PHP --format enhancedchm --docbook
D:\PHP\Manual\PHP\doc-all\doc-base\.manual_en.xml --lang=en --output
D:\PHP\Manual\rendering\PHP\en --color true --css reset.css --css theme.css
--css doc.css --saveconfig=true

the debug output looks like array(8) {
  ["package"]=>
  string(3) "PHP"
  ["format"]=>
  string(11) "enhancedchm"
  ["docbook"]=>
  string(49) "D:\PHP\Manual\PHP\doc-all\doc-base\.manual_en.xml"
  ["lang"]=>
  string(2) "en"
  ["output"]=>
  string(30) "D:\PHP\Manual\rendering\PHP\en"
  ["color"]=>
  string(4) "true"
  ["css"]=>
  array(3) {
    [0]=>
    string(9) "reset.css"
    [1]=>
    string(9) "theme.css"
    [2]=>
    string(7) "doc.css"
  }
  ["saveconfig"]=>
  string(4) "true"
}

Which is a lot better.

Amending the checkOptions() method to ignore the =xxxx content, seems to
work as I would expect ...

    private function checkOptions() {
        $argv = $_SERVER['argv'];
        $argc = $_SERVER['argc'];

        $short = str_split(str_replace(':', '', $this->getShortOptions()));
        $long = array();
        foreach ($this->getLongOptions() as $opt) {
            $long[] = str_replace(':', '', $opt);
        }

        for ($i=1; $i < $argc; $i++) {
            $equal_pos = strpos($argv[$i], '=');
            if (substr($argv[$i], 0, 2) == '--') {
                if (!in_array($check = substr($argv[$i], 2, $equal_pos ?
$equal_pos - 2 : strlen($argv[1])), $long)) {
                    trigger_error('Invalid long option ' . $argv[$i] . ' '
. $check, E_USER_ERROR);
                }
            } elseif (substr($argv[$i], 0, 1) == '-') {
                if (!in_array(substr($argv[$i], 1, $equal_pos ? $equal_pos
- 1 : strlen($argv[1])), $short)) {
                    trigger_error('Invalid short option ' . $argv[$i],
E_USER_ERROR);
                }
           }
        }
    }


But I'm not sure if this is a windows only issue?

Can anyone check this please?

Thanks,

Richard.
-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : http://e-e.com/M_248814.html


: http://bit.ly/9O8vFY

Reply via email to