cvs: phd / config.php

From: Date: Sat, 03 Nov 2007 13:19:51 +0000
Subject: cvs: phd / config.php
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-332@lists.php.net to get a copy of this message
bjori Sat Nov 3 13:19:51 2007 UTC Modified files: /phd config.php Log: Add version info and help options http://cvs.php.net/viewvc.cgi/phd/config.php?r1=1.7&r2=1.8&diff_format=u Index: phd/config.php diff -u phd/config.php:1.7 phd/config.php:1.8 --- phd/config.php:1.7 Fri Oct 26 15:07:25 2007 +++ phd/config.php Sat Nov 3 13:19:51 2007 @@ -1,5 +1,5 @@ <?php -/* $Id: config.php,v 1.7 2007/10/26 15:07:25 bjori Exp $ */ +/* $Id: config.php,v 1.8 2007/11/03 13:19:51 bjori Exp $ */ function v($msg) { $args = func_get_args(); @@ -18,6 +18,7 @@ define('VERBOSE_ALL',VERBOSE_INDEXING|VERBOSE_FORMAT_RENDERING|VERBOSE_THEME_RENDERING|VERBOSE_RENDER_STYLE|VERBOSE_PARTIAL_READING|VERBOSE_PARTIAL_CHILD_READING|VERBOSE_TOC_WRITING|VERBOSE_CHUNK_WRITING); +define("PHD_VERSION", "0.2.0-dev"); $OPTIONS = array ( 'output_format' => array('xhtml'), @@ -49,18 +50,19 @@ ); -$short = "vf:t:i:d:p:"; -$long = array( - "The build format to use" => "format:", - "The output theme to use" => "theme:", - "Regenerate the index or not" => "index:", - "The file to render from" => "docbook:", - "The IDs to render" => "partial:", - "Adjust the verbosity level" => "verbose:", +$opts = array( + "format" => "f:", // The format to render (xhtml, pdf...) + "theme:" => "t:", // The theme to render (phpweb, bightml..) + "index:" => "i:", // Re-index or load from cache + "docbook:" => "d:", // The Docbook XML file to render from (.manual.xml) + "partial:" => "p:", // The ID to render (optionally ignoring its childrens) + "verbose:" => "v", // Adjust the verbosity level + "version" => "V", // Print out version information + "help" => "h", // Print out help ); $verbose = 0; -$args = getopt($short, $long); +$args = getopt(implode("", array_values($opts)), array_keys($opts)); foreach($args as $k => $v) { switch($k) { /* {{{ Docbook file */ @@ -179,6 +181,39 @@ break; /* }}} */ + case "V": + case "version": + v("PhD version: %s\n", PHD_VERSION); + v("Copyright (c) 2007 The PHP Documentation Group"); + exit(0); + + case "usage": + case "help": + case "h": + echo "PhD version: " .PHD_VERSION; + echo "\nCopyright (c) 2007 The PHP Documentation Group\n + -v + --versbose <int> Adjusts the verbosity level. + -f <formatname> + --format <formatname> The build format to use + -t <themename> + --theme <themename> The theme to use + -i + --index Index before rendering or load from cache [NOTE: Not supported yet] + -d <filename> + --docbook <filename> The Docbook file to render from + -p <id[=bool]> + --partial <id[=bool]> The ID to render, optionally ignoring its children pages (default to true; render childrens) + -V + --version Print the PhD version information + -h + --help This help + +All options can be passed multiple times for greater affect. +NOTE: Long options are only supported using PHP5.3\n"; + exit(0); + break; + default: v("Hmh, something weird has happend, I don't know this option"); var_dump($k, $v); @@ -189,7 +224,7 @@ if ($argc == 2) { $OPTIONS["xml_root"] = $argv[1]; -} elseif (is_file($argv[$argc-1]) && $OPTIONS["xml_file"] != $argv[$argc-1]) { +} elseif ($argc > 2 && is_file($argv[$argc-1]) && $OPTIONS["xml_file"] != $argv[$argc-1]) { $OPTIONS["xml_file"] = $argv[$argc-1]; $OPTIONS["xml_root"] = dirname($argv[$argc-1]); }

« previous php.doc.cvs (#332) next »