Argv multimethod

Methods

Argv(h:Hash) Source: stdlib.ngs:6158
Convert a Hash, describing command line arguments, to array of strings, appropriate for using as argument to external process. Key-value pairs with values of type NoData (null, EmptyBox) are discarded. Key-value pairs with empty array values are discarded. Values of type Box are unboxed. For keys which are arrays of two elements, Bool value selects first (for true) or second (for false) element. For keys which are arrays of a single element, Bool value selects whether the key is present or absent in the output. For keys which are Repeat, Eachable1 value causes the switch to be repeated for each element, building switch name and switch value pairs.

Example

# Typical usage:
argv = Argv({'name1': value1, 'name2': value2, ...})
$(my_command $*argv)
# Handling of key-value pairs
Argv({"--a": 1, "-b": null})                         # ['--a', 1]
Argv({["-y1", "-n1"]: true, ["-y2", "-n2"]: false})  # ['-y1', '-n2']
Argv({["-y3"]: true, ["-y4"]: false})                # ["-y3"]
Argv({Repeat("--repeat"): ["a", "b"]})               # ["--repeat", "a", "--repeat", "b"]
Argv({"-a1": [], "-a2": [1,2,3]})                    # ["-a2", 1, 2, 3]
Argv(a:Arr)deprecated Source: stdlib.ngs:6202
Deprecated. Do not use!