NAME
util::argv - optex argument utility modules
SYNOPSIS
optex command -Mutil::argv
DESCRIPTION
This module is a collection of sample utility functions for command optex.
Function can be called with option declaration. Parameters for the function are passed by name and value list: name=value. Value 1 is assigned for the name without value.
In this example,
optex -Mutil::argv::function(debug,message=hello,count=3)option debug has value 1, message has string "hello", and count also has string "3".
FUNCTION
- times(count=n,suffix=str)
- 
Multiply each arguments. Default count is 2. % optex echo -Mutil::argv::times(count=3) 1 2 3 1 1 1 2 2 2 3 3 3Put suffix to duplicated arguments. % optex echo -Mutil::argv::times(suffix=.bak) a b c a a.bak b b.bak c c.bak
- reverse()
- 
Reverse arguments. 
- collect(index=2:4:6)
- 
Collect arguments. % optex echo -Mutil::argv::collect(index=2:4:6) 1 2 3 4 5 6will print: 2 4 6
- proc()
- 
Process substitution. % optex diff -Mutil::argv::proc= '<(date)' '<(date -u)'
- filter(command=command)
- 
Execute filter command for each file. Specify any command which should be invoked for each argument. % optex diff -Mutil::argv::filter=command='cat -n' foo barIn this example, fooandbarare replaced by the result output ofcat -n < fooandcat -n < bar. The replacement only occurs when the file corresponding to the argument exists.
OPTIONS
Several options are prepared and enabled by request. To enable specific option, use enable function like this to enable --move and --copy options.
-Mutil::argv::enable=move,copyParameter :all can be used to enable everything.
-Mutil::argv::enable=:allYou can use alternative names:
-Mutil::argv::enable(move=mymove,copy=mycopy)- --move param
- --remove param
- --copy param
- 
These options are converted $<command(param)>notation, where param is offset or offset,length.--move 0 moves all following arguments there, --remove 0 just removes them, and --copy 0 copies them. --move 0,1 moves following argument (which does not change anything), and --move 1,1 moves second argument (exchange following two). --move -1 moves the last argument. --copy 0,1 duplicates the next. 
- --exch
- 
Exchanges following two arguments. This is same as --move 1,1. optex -Mutil::argv::enable=exch echo --exch foo barwill print: bar foo
- --filter command
- 
Set input filter for each file argument. Next command passes the result of the expandfilter to thecat -nfor each file in the command line.optex -Mutil::argv::enable=filter cat -n --filter=expand a b c
Following options are interface for builtin functions.