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 3
Put 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 6
will print:
2 4 6
- proc()
-
Process substitution.
% optex diff -Mutil::argv::proc= '<(date)' '<(date -u)'
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,copy
Parameter :all can be used to enable everything.
-Mutil::argv::enable=:all
You can use alternative names:
-Mutil::argv::enable(move=mynove,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 bar
will print:
bar foo
Following options are interface for builtin functions.