0%

Parse Line Str to Command Args

parse line str to command args

1
2
3
4
5
6
7
8
9
10
11
12
var commandLine = @"1 2";

var args = commandLine
.ParseCommandArgsLine()
.ToArray();

var expected = new[]
{
"1",
"2"
};
expected.ToExpectedObject().ShouldEqual(args);

ParseCommandArgs will cut the string according to single or double quotation marks.

1
2
3
4
5
6
7
8
9
10
11
12
13
var commandLine = @"1 '2 3'";

var args = commandLine
.ParseCommandArgsLine()
.ToArray();

var expected = new[]
{
"1",
"'2 3'"
};

expected.ToExpectedObject().ShouldEqual(args);