extractCommandNameArgument

Extract the command name from the argument list

extractCommandNameArgument
(
string[] args
)

Parameters

args string[]

a list of string arguments that will be processed

Return Value

Type: auto

A structure with two members. value is the command name remaining is a list of unprocessed arguments

Examples

test extractCommandNameArgument usage

/// It returns an empty string on when there are no args
assert(extractCommandNameArgument([]).value == "");
assert(extractCommandNameArgument([]).remaining == []);

/// It returns the first argument when it does not start with `-`
assert(extractCommandNameArgument(["test"]).value == "test");

/// There is nothing to extract when the arguments only contain the `test` cmd
assert(extractCommandNameArgument(["test"]).remaining == []);

/// It extracts two arguments when they are not a command
assert(extractCommandNameArgument(["-a", "-b"]).remaining == ["-a", "-b"]);

/// It returns the an empty string when it starts with `-`
assert(extractCommandNameArgument(["-test"]).value == "");

Meta