Revision [1425]

Last edited on 2010-05-19 07:47:31 by DavidLee
Additions:
if -i is specified then all options in the ignore optstring are ignored and not output in the result.


Revision [1424]

Edited on 2010-05-19 07:39:32 by DavidLee
Additions:
||i,ignore optstring||Option string to ignore||
If -p is specified then an additional optstring is used as a "pass through". All arguments which match the passthrough optstring are serialized as is and remaining arguments are ignored. This is useful for a command to 'pass through' known arguments to another command.
Deletions:
If -p is specified then an additional optstring (which should be a subset of the main optstring) is used as a "pass through". All arguments which match the passthrough optstring are serialized as is and remaining arguments are ignored. This is useful for a command to 'pass through' known arguments to another command.


Revision [1422]

Edited on 2010-05-19 07:17:38 by DavidLee
Additions:
===Required Options===
Note that there is no concept of "required" options. Its up to the application to check if options are supplied.
====Passthrough Options====
Using -p passthrough-options allows xgetops to parse an argument list only evalutating the passthrough-options and ignoring the main options.
This is useful in modules or scripts that implement a common set of options by another script or command but extend those options or get at the list of non-option arguments.
Example from the implementation of [[MarkLogicGet MarkLogic get]] command
_opts=$<(xgetopts -a -p "c=connect:,t=text" -ps -- "$@")
shift $?
for uri ; do
:query $_opts -q "doc(\"$uri\")"
done
This collects all optional options used by the [[MarkLogicQuery MarkLogic query]] command (-c,-t) into the _opts variable as a sequence, then sets $* to the remaining options.
The -a option causes xgetopts to exit with a return status of the first non-option arguement so the "shift $?" will discard all option arguments leaving the remaining args in $*.
The [[MarkLogicQuery :query]] command is then passed any -c or -t option specified
Deletions:
So note that omitted, required arguments don't produce any exception


Revision [1421]

Edited on 2010-05-19 07:00:31 by DavidLee
Deletions:
**phase=<[ $args/xgetopts/options/option[@name='p']/value/text()]>
echo Phase is ${phase}**


Revision [1374]

Edited on 2010-05-11 05:16:43 by DavidLee
Additions:
phase=<[ $args/xgetopts/options/option[@name='p']/value/text()]>
**phase=<[ $args/xgetopts/options/option[@name='p']/value/text()]>
argcount=<[ count($args/xgetopts/options/option)]>
Deletions:
phase= <[ $args/xgetopts/options/option[@name='p']/value/text()]>
**phase= <[ $args/xgetopts/options/option[@name='p']/value/text()]>
argcount= <[ count($args/xgetopts/options/option)]>


Revision [1373]

Edited on 2010-05-11 04:29:55 by DavePawson [Added arg count]
Additions:
===Argument count===
From the above example, to retrieve the count of options
argcount= <[ count($args/xgetopts/options/option)]>
echo $argcount args
So note that omitted, required arguments don't produce any exception


Revision [1372]

Edited on 2010-05-11 04:23:34 by DavePawson [Added arg count]
Additions:
**xgetopts "p:,o:,d:+" $* >{args} ** says that the p, o and d parameters are required and come from the command line. the output is put into the 'args' variable.
**phase= <[ $args/xgetopts/options/option[@name='p']/value/text()]>
echo Phase is ${phase}**
Deletions:
xgetopts "p:,o:,d:+" $* >{args} says that the p, o and d parameters are required and come from the command line. the output is put into the 'args' variable.


Revision [1371]

Edited on 2010-05-11 04:21:48 by DavePawson [amended options->optstring, added example]
Additions:
xgetopts [optstring] [--] args
From within a script:
xgetopts "p:,o:,d:+" $* >{args}
echo $args
phase= <[ $args/xgetopts/options/option[@name='p']/value/text()]>
echo Phase is ${phase}
shows as
<option name="p">
<value>phase1</value>
<option name="o">
<value>test.xml</value>
<option name="d">
<value>dir1</value>
<value>dir2</value>
<args/>
Phase is phase1
xgetopts "p:,o:,d:+" $* >{args} says that the p, o and d parameters are required and come from the command line. the output is put into the 'args' variable.
phase= <[ $args/xgetopts/options/option[@name='p']/value/text()]>
echo Phase is ${phase}
These lines extract the value of the p option and echo it to stdout.
Deletions:
xgetopts [options] [--] args


Revision [1370]

Edited on 2010-05-11 02:14:55 by DavePawson [typo, omits -> emits]
Additions:
xgetopts runs the internal shell command option processor (Options) and emits the result as an XML document.
Deletions:
xgetopts runs the internal shell command option processor (Options) and omits the result as an XML document.


Revision [1326]

Edited on 2010-03-23 08:05:19 by DavidLee [typo, omits -> emits]
Additions:
if -a is specified then the exit code is the relative position of the first non-option argument. This allows options to be parsed then remaining arguments shifted into $1 ... $N by using "shift $?"


Revision [1325]

Edited on 2010-03-23 08:04:06 by DavidLee [typo, omits -> emits]
Additions:
||a,argindex||Exit with argument index||


Revision [1315]

Edited on 2010-03-21 14:55:57 by DavidLee [typo, omits -> emits]
Additions:
||[+]ps=pass-serialize||Add (+ do not add) standard serialization options to passthrough||
Deletions:
||[+]ps=pass-serialize||Add (+do not add) standard serialization options to passthrough||


Revision [1314]

Edited on 2010-03-21 14:55:24 by DavidLee [typo, omits -> emits]
Additions:
xgetopts [options] [--] args
||o,optdef optstring||Option string||
||c,command cmdname||Command name||
||p,passthrough optstring||pass through options||
||[+]s,serialize||Add (+ do not add) standard serialization options to optstring||
||[+]ps=pass-serialize||Add (+do not add) standard serialization options to passthrough||
||noargs||Do no output additional arguments||
||novalues||Do not output argument values||
args 0 or more arguments to be parsed using the optstring, typically $*
If no -o or -p is given then the first argument is the optstring.
If -p is specified then an additional optstring (which should be a subset of the main optstring) is used as a "pass through". All arguments which match the passthrough optstring are serialized as is and remaining arguments are ignored. This is useful for a command to 'pass through' known arguments to another command.
if -novalues is specified then the character content of values are not output. This is useful for parameters which are not serializable or may be very large.
if -noargs is specified then the args element is omitted.
Deletions:
xgetopts [options]
o=optdef:,c=command:,p=passthrough:,+s=seralize,+ps=pass-serialize,noargs,novalues
||foo||
args 0 or more arguments to be parsed using the optstring, typically $*


Revision [1313]

Edited on 2010-03-21 14:45:55 by DavidLee [typo, omits -> emits]
Additions:
xgetopts [options]
====Options====
o=optdef:,c=command:,p=passthrough:,+s=seralize,+ps=pass-serialize,noargs,novalues
||foo||
Deletions:
xgetopts optstring [args]


Revision [1043]

Edited on 2009-11-25 18:14:22 by DavidLee [typo, omits -> emits]
Additions:
[[Commands]]


Revision [1042]

Edited on 2009-11-25 18:13:57 by DavidLee [typo, omits -> emits]
Additions:
====Examples====
Example
xgetopts "a=all,b:,c:+" -all -c c1 -c c2 arg1 arg2
Result
Deletions:
====Example====
$ xgetopts "a=all,b:,c:+" -all -c c1 -c c2 arg1 arg2


Revision [786]

Edited on 2009-09-16 08:01:55 by DavidLee [typo, omits -> emits]
Deletions:
[[CommandsInternal]]


Revision [376]

Edited on 2009-01-05 04:33:40 by DavidLee [typo, omits -> emits]
Additions:
====Synopsis====
xgetopts optstring [args]
====Description====
===optstring===
Deletions:
======xgetopts optstring [args]======
====optstring====


Revision [375]

Edited on 2009-01-05 04:32:18 by DavidLee [typo, omits -> emits]
Additions:
======Command xgetopts======
====Name====
**xgetopts** parses command line options


Revision [350]

Edited on 2009-01-03 07:10:35 by DavidLee [typo, omits -> emits]
Additions:
----
[[CategoryCommands]]
[[CommandsInternal]]


Revision [348]

Edited on 2009-01-03 06:55:46 by DavidLee [typo, omits -> emits]

No Differences

Revision [347]

The oldest known version of this page was created on 2009-01-03 06:55:37 by DavidLee [typo, omits -> emits]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki