Skip to content

Commit f31607d

Browse files
committed
Update ArgumentsManager.cs
Add parse verification and replace spaces into tabulations
1 parent 496fd6b commit f31607d

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

ProgramArgumentsManager/ArgumentsManager.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,23 @@ public void Parse(string[] args)
102102
string lastArg = null;
103103
foreach (string arg in args)
104104
{
105-
if (IsArgument(arg))
105+
try
106106
{
107-
lastArg = arg;
108-
_options[lastArg].Specified = true;
107+
if (IsArgument(arg))
108+
{
109+
lastArg = arg;
110+
_options[lastArg].Specified = true;
111+
}
112+
else
113+
{
114+
_options[lastArg].Values.Add(arg);
115+
}
109116
}
110-
else
117+
catch (KeyNotFoundException)
111118
{
112-
_options[lastArg].Values.Add(arg);
119+
int i = lastArg is null ?
120+
throw new FirstNoArgumentException($"The first command ({arg}) isn't an argument !") :
121+
throw new UnknownArgumentException(lastArg, $"{lastArg} doesn't exist !");
113122
}
114123
}
115124

0 commit comments

Comments
 (0)