From 77300bbcab173f3187b6ea1bbe8be7150c2288f8 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Mon, 1 Oct 2007 13:32:17 +0000 Subject: getopt documentation --- it.class | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'it.class') diff --git a/it.class b/it.class index 0092e86..3db36c1 100644 --- a/it.class +++ b/it.class @@ -401,15 +401,19 @@ function imageconvert($p) /** - * Parse command line options with Usage given as template. Example: + * Parse command line options with Usage given as template and return assoc array. Example: (like grep --help) * Usage: myprogram.php [OPTIONS] PATTERN * -s, --short Use short ouput * -f, --file=FILE Use FILE for input * -x EXTENSION Ignore EXTENSION - * Value always stored in long opt. Use double blank before explanation. Non-option text ignored. - * Mandatory non-option arguments are stored under their lowercased name. + * Mandatory arguments from the Usage: line are returned under their (lowercased!) name. + * All non-option arguments are returned in 'args' + * Option text must be indented; if long and short option present, value is stored in long option + * Options without arguments store true or false under their key + * Options -h and --help will be handled internally by printing usage and exiting + * Two or more blanks must be in front of option explanation * @param $helplines Usage parsed to determine options - * @return Associative array of opts: Boolean options are set to true, remaining args returned in 'args' + * @return Associative array of options */ function getopt($helplines) { -- cgit v1.2.3