pike.git / lib / modules / Getopt.pmod

version» Context lines:

pike.git/lib/modules/Getopt.pmod:26:         //! This is a generic function to parse command line options of the   //! type @tt{-f@}, @tt{--foo@} or @tt{--foo=bar@}.   //!   //! @param argv   //! The first argument should be the array of strings that was sent as   //! the second argument to your @tt{main()@} function.   //!   //! @param shortform - //! The second is a string with the short form of your option. - //! The short form must be only one character long. + //! The second is a string with the short form of your option. The + //! short form must be only one character long. It can also be an + //! array of strings, in which case any of the options in the array + //! will be accepted.   //!   //! @param longform - //! This is an alternative and maybe more readable way to - //! give the same option. If you give @tt{"foo"@} as @[longform] your program - //! will accept @tt{--foo@} as argument. + //! This is an alternative and maybe more readable way to give the + //! same option. If you give @tt{"foo"@} as @[longform] your program + //! will accept @tt{--foo@} as argument. This argument can also be + //! an array of strings, in which case any of the options in the + //! array will be accepted.   //!   //! @param envvars - //! This argument specifies the environment variables that can be - //! used to specify the same option. This option exists to make it easier - //! to customize program usage. + //! This argument specifies an environment variable that can be used + //! to specify the same option, to make it easier to customize + //! program usage. It can also be an array of strings, in which case + //! any of the mentioned variables in the array may be used.   //!   //! @param def   //! This argument has two functions: It specifies if the option takes an   //! argument or not, and it informs @[find_option()] what to return if the   //! option is not present. If @[def] is given and the option does not have an   //! argument @[find_option()] will fail.   //!   //! @param throw_errors   //! If @[throw_errors] has been specified @[find_option] will throw errors   //! on failure. If it has been left out, or is @tt{0@} (zero), it will - //! instead print an error message and exit the program on failure. + //! instead print an error message on @[Stdio.stderr] and exit the + //! program with result code 1 on failure.   //! - //! Also, as an extra bonus: @[shortform], @[longform] and @[envvars] can - //! all be arrays, in which case any of the options in the array will be - //! accepted. - //! +    //! @returns   //! Returns the value the option has been set to if any.   //!   //! If the option is present, but has not been set to anything @tt{1@}   //! will be returned.   //!   //! Otherwise if any of the environment variables specified in @[envvars] has   //! been set, that value will be return.   //!   //! If all else fails, @[def] will be returned.
pike.git/lib/modules/Getopt.pmod:256:   //! @endarray   //!   //! Only the first three elements need to be included.   //!   //! @param posix_me_harder   //! Don't scan for arguments after the first non-option.   //!   //! @param throw_errors   //! If @[throw_errors] has been specified @[find_all_options()] will throw   //! errors on failure. If it has been left out, or is @tt{0@} (zero), it will - //! instead print an error message and exit the program on failure. + //! instead print an error message on @[Stdio.stderr] and exit the + //! program with result code 1 on failure.   //!   //! @returns   //! The good news is that the output from this function is a lot simpler.   //! @[find_all_options()] returns an array where each element is an array on   //! this form:   //! @array   //! @elem string name   //! Option identifier name from the input.   //! @elem mixed value   //! Value given. If no value was specified, and no default has been
pike.git/lib/modules/Getopt.pmod:419:   }      //! This function returns the remaining command line arguments after   //! you have run @[find_options()] or @[find_all_options()] to find   //! all the options in the argument list. If there are any options   //! left not handled by @[find_options()] or @[find_all_options()]   //! this function will fail.   //!   //! If @[throw_errors] has been specified @[get_args()] will throw errors   //! on failure. If it has been left out, or is @tt{0@} (zero), it will - //! instead print an error message and exit the program on failure. + //! instead print an error message on @[Stdio.stderr] and exit the + //! program with result code 1 on failure.   //!   //! @returns   //! On success a new @[argv] array without the parsed options is   //! returned.   //!   //! @seealso   //! @[Getopt.find_option()], @[Getopt.find_all_options()]   //!   array(string) get_args(array(string) argv, void|int posix_me_harder,    void|int throw_errors)