options.bi | |
License | Copyright © 2009, FreeBASIC Extended Library Development Group |
ext. options | |
Parser | Provides an easy way to process command line arguments. |
Functions | |
addOption | Adds an option to the parser. |
parse | Parses the command line and prepares the results. |
hasError | Returns true if there was an error parsing the command line. |
getError | Returns a string describing the error. |
isSet | Was the option passed on the command line? |
getArg | |
getRemainder | All unparsed content from the command line. |
Copyright © 2009, FreeBASIC Extended Library Development Group
Contains code contributed and Copyright © 2007, mr_cha0s: ruben@gmai l.com .coder
Distributed under the FreeBASIC Extended Library Group license. See accompanying file LICENSE.txt or copy at http://code.google.com- /p- /fb-extended-lib- /wiki- /License
Provides an easy way to process command line arguments. Supports short (-c) and long (--command) style arguments with optional and required parameters.
Functions | |
addOption | Adds an option to the parser. |
parse | Parses the command line and prepares the results. |
hasError | Returns true if there was an error parsing the command line. |
getError | Returns a string describing the error. |
isSet | Was the option passed on the command line? |
getArg | |
getRemainder | All unparsed content from the command line. |
declare function addOption( byref short_opt as string, byref long_opt as string = "", byval has_arg as bool = false, byval arg_required as bool = false, byval can_repeat as bool = false, byref rep_seperator as string = ";" ) as integer
Adds an option to the parser.
short_opt | Single letter version of the option, e.g. c for -c |
long_opt | (optional) long form version of the option, e.g. copy for --copy |
has_arg | (optional) option has argument, defaults to false, e.g. --copy filename where filename is the argument |
arg_required | (optional) is the argument required, defaults to false |
can_repeat | (optional) can the argument repeat, defaults to false, e.g. --copy file1 --copy file2 |
rep_seperator | (optional) if the argument can repeat what should the results be seperated by, defaults to “;” |
declare function isSet( byval index as integer ) as bool
Was the option passed on the command line?
index | Identifier returned from addOption for an option. |
True if the option was passed on the command line.
declare function getArg( byval index as integer ) as string
index | Identifier returned from addOption for an option. |
String containing the argument passed to this option optionally seperated by the seperator if there is more than one result.
Adds an option to the parser.
declare function addOption( byref short_opt as string, byref long_opt as string = "", byval has_arg as bool = false, byval arg_required as bool = false, byval can_repeat as bool = false, byref rep_seperator as string = ";" ) as integer
Parses the command line and prepares the results.
declare sub parse( byval argc as integer, byval argv as zstring ptr ptr )
Returns true if there was an error parsing the command line.
declare function hasError() as bool
Returns a string describing the error.
declare function getError() as string
Was the option passed on the command line?
declare function isSet( byval index as integer ) as bool
declare function getArg( byval index as integer ) as string
All unparsed content from the command line.
declare function getRemainder() as string