Skip to content

Commit

Permalink
Modify argsClass.ch
Browse files Browse the repository at this point in the history
  • Loading branch information
Enrique Ortiz committed Jul 9, 2019
1 parent 167e45b commit 28def90
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions ConsoleArgsParser/CodeKatas/ArgsClass.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace ArgsConsole
{
Expand Down Expand Up @@ -111,17 +110,9 @@ public Dictionary<string, string> GeneralSParse(string args)
}

if ((chain[i].Length == 2 && chain[i][0] == '-') || (chain[i].Length == 3 && chain[i].Contains("--"))) { }

else
{
throw new InvalidArgException();
}/*
if ((schems[chain[i]]=="false" || schems[chain[i]] == "true"))
{ //if(chain[i + 1][0] == '-')
throw new InvalidArgException();
}*/

//dict.Remove(chain[i]);
if (schems[chain[i]] == "false")
dict.Add(chain[i], "true");
else
Expand All @@ -133,9 +124,7 @@ public Dictionary<string, string> GeneralSParse(string args)

}
else
{
throw new InvalidArgException();
}
}
}
return dict;
Expand All @@ -160,6 +149,7 @@ public Dictionary<string, string> GeneralSParse(string[] args)
var dict = new Dictionary<string, string>();
if (args != null || args.Length == 0)
{
chain = args;
int cant = chain.Length;
for (int i = 0; i < cant; i++)
{
Expand All @@ -177,11 +167,7 @@ public Dictionary<string, string> GeneralSParse(string[] args)
}
if ((chain[i].Length != 2 && chain[i][0] != '-') || (chain[i].Length != 3 && chain[i].Contains("--")))
throw new InvalidArgException();
/*
if ((schems[chain[i]]=="false" || schems[chain[i]] == "true"))
{ //if(chain[i + 1][0] == '-')
throw new InvalidArgException();
}*/

dict.Remove(chain[i]);
if (schems[chain[i]] == "false")
dict.Add(chain[i], "true");
Expand Down Expand Up @@ -229,9 +215,7 @@ public Dictionary<string, bool> BoolArgs(string[] scheme, string args)
if (command.Length != 2 || command[0] != '-')
throw new InvalidSchemeException();
else
{
dict.Add(command, false);
}
}
if (args != null)
{
Expand All @@ -247,10 +231,7 @@ public Dictionary<string, bool> BoolArgs(string[] scheme, string args)
dict.Add(item, true);
}
else
{
throw new InvalidArgException();
}

}
}
return dict;
Expand Down

0 comments on commit 28def90

Please sign in to comment.