Argv multimethod


Argv(h:Hash) Source: stdlib.ngs:4938
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 arrays of a single element, Eachable1 value causes the switch to br repeated for each element, building switch name and switch value pairs.


# 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"]: ["a", "b"]})                     # ["--repeat", "a", "--repeat", "b"]
Argv({"-a1": [], "-a2": [1,2,3]})                    # ["-a2", 1, 2, 3]
Argv(a:Arr) Source: stdlib.ngs:4976