pike.git / lib / modules / Getopt.pmod

version» Context lines:

pike.git/lib/modules/Getopt.pmod:190:   //! This function does the job of several calls to @[find_option()].   //! The main advantage of this is that it allows it to handle the   //! @tt{@b{POSIX_ME_HARDER@}@} environment variable better. When the either   //! the argument @[posix_me_harder] or the environment variable   //! @tt{@b{POSIX_ME_HARDER@}@} is true, no arguments will be parsed after   //! the first non-option on the command line.   //!   //! Each element in the array @[options] should be an array on the   //! following form:   //! @array - //! @element string name + //! @elem string name   //! Name is a tag used to identify the option in the output. - //! @element int type + //! @elem int type   //! Type is one of @[Getopt.HAS_ARG], @[Getopt.NO_ARG] and   //! @[Getopt.MAY_HAVE_ARG] and it affects how the error handling   //! and parsing works.   //! You should use @[HAS_ARG] for options that require a path, a number or   //! similar. @[NO_ARG] should be used for options that do not need an   //! argument, such as @tt{--version@}. @[MAY_HAVE_ARG] should be used   //! for options that may or may not need an argument. - //! @element string|array(string) aliases + //! @elem string|array(string) aliases   //! This is a string or an array of string of options that will be   //! looked for. Short and long options can be mixed, and short options   //! can be combined into one string. Note that you must include the dashes   //! so that @[find_all_options()] can distinguish between   //! long and short options. Example: @tt{({"-tT","--test"})@}   //! This would make @[find_all_options] look for @tt{-t@},   //! @tt{-T@} and @tt{--test@}. - //! @element void|string|array(string) env_var + //! @elem void|string|array(string) env_var   //! This is a string or an array of strings containing names of   //! environment variables that can be used instead of the   //! command line option. - //! @element void|mixed default + //! @elem void|mixed default   //! This is the default value the option will have in the output   //! from this function. Options without defaults will be omitted   //! from the output if they are not found in argv.   //! @endarray   //!   //! Only the first three elements need to be included.   //!   //! @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 - //! @element string name + //! @elem string name   //! Option identifier name from the input. - //! @element mixed value + //! @elem mixed value   //! Value given. If no value was specified, and no default has been   //! specified, the value will be 1.   //! @endarray   //!   //! @note   //! @[find_all_options()] modifies @[argv].   //!   //! @seealso   //! @[Getopt.get_args()], @[Getopt.find_option()]   //!