Skip to content

Commit

Permalink
Modify command line parse method to scan entire array of arguments. A…
Browse files Browse the repository at this point in the history
…lso added to default case to enable halt if unknown argument is found.
  • Loading branch information
redleek committed Jan 5, 2015
1 parent a6481c0 commit ddfab6d
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 42 deletions.
77 changes: 39 additions & 38 deletions TacticalSpaceCheeseRacer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,50 +139,51 @@ static void ReadNames()
/// <param name="args">Array that contains the arguments.</param>
static void ParseCLA(string[] args)
{
try
{
switch (args[0])
for (int argument = 0; argument < args.Length; argument++)
{
#if DEBUG
case "--test-enable":
case "-t":
// Allow automatic use of the testing input variables.
debugmode = true;
break;
Console.WriteLine("DEBUG ARGS: On argument number: {0}", argument);
#endif
case "--help":
case "-h":
// Print out command line help.
StreamReader reader;
try
switch (args[argument])
{
reader = new StreamReader(@"README.md");
#if DEBUG
case "--test-enable":
case "-t":
// Allow automatic use of the testing input variables.
debugmode = true;
break;
#endif
case "--help":
case "-h":
// Print out command line help.
StreamReader reader;
try
{
reader = new StreamReader(@"README.md");
}
catch
{
PrintLine("Help file `README.md' not found! If found, please place in the same directory as the program.");
Environment.Exit(0);
}
while (true)
{
string line = reader.ReadLine();
if (line == null)
{
break;
}
PrintLine(line);
}
reader.Close();
Environment.Exit(0);
break;
default:
Console.WriteLine("ERROR: \"{0}\" is not a known argument.", args[argument]);
Environment.Exit(1);
break;
}
catch
{
PrintLine("Help file `README.md' not found! If found, please place in the same directory as the program.");
Environment.Exit(0);
}
while (true)
{
string line = reader.ReadLine();
if (line == null)
{
break;
}
PrintLine(line);
}
reader.Close();
Environment.Exit(0);
break;
default:
break;
}
}
catch
{
// Ignore as there are no command line argumets to parse.
}

return;
}
Expand Down
8 changes: 8 additions & 0 deletions TacticalSpaceCheeseRacer/TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
USER INTERFACE
==============
* Create welcome screen.
* Finish more methods for formatted string printing with `Print' method.

METHODS
=======
* Parse all the command line arguments instead of executing them one by one and make default case in switch statement create an exception.
4 changes: 0 additions & 4 deletions TacticalSpaceCheeseRacer/TODO.txt

This file was deleted.

0 comments on commit ddfab6d

Please sign in to comment.