using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Systin.Library;
using TownleyEnterprises.Command;
namespace Systin_Console{
class Program
{
#region SystinOptions Class
private class SystinOptions : ICommandListener
{
private string mInputFile = "";
public string InputFile
{
get { return mInputFile; }
}
private string mDriver = "";
public string Driver
{
get { return mDriver; }
}
#region Command Options
private static CommandOption _inputFile = new CommandOption("InputFile",
'i', true, null,
"Path to Test File");
private static CommandOption _languageDriver = new CommandOption(
"Driver",
'd',
true,
null,
"specify the path to the language Library dll");
private static CommandOption[] _mainopts = {
_inputFile, _languageDriver };
#endregion
#region ICommandListener Members
public string Description
{
get { return "Description of stuff"; }
}
public CommandOption[] Options
{
get { return _mainopts; }
}
public void OptionMatched(CommandOption opt, string arg)
{
if(opt.LongName.Equals("InputFile")){
this.mInputFile = opt.ArgValue.ToString();
}
if(opt.LongName.Equals("Driver")){
this.mDriver = opt.ArgValue.ToString();
}
}
#endregion
}
#endregion
#region Private Util Methods
private int Run(string[] cmdLine)
{
return 0;
}
private void ProcessSingleLanguageDll()
{
//FileInfo inputFile = ValidateFile();
//DllLoader dllLoader = DllLoader.LoadDll(inputFile);
}
private void DetermineUnhandledArguments()
{
// For error handling, were any switches handled?
//string[] unhandled = parser.UnhandledSwitches;
//if (unhandled.Length > 0)
//{
// Console.WriteLine("\nThe following switches were not handled.");
// foreach (string s in unhandled)
// Console.WriteLine(" - {0}", s);
//}
}
#endregion
#region Main Method
[STAThread]
static int Main(string[] args)
{
//Parse the command Line looking for options
CommandParser _parser = new CommandParser("Systin");
SystinOptions options = new SystinOptions();
_parser.AddCommandListener(options);
_parser.Parse(args);
//If either inputfile or driver is empty thow an error message
if (options.InputFile.Length == 0 || options.Driver.Length == 0)
{
Console.WriteLine("InputFile and Driver path are both required parameters");
_parser.Usage();
return -1;
}
//Make sure both files are actual files
FileInfo testInputFile = Validate(options.InputFile.ToString());
FileInfo languageDriver = Validate(options.Driver.ToString());
//Process Input Test File
TestFileLoader fr = TestFileLoader.OpenAndProcessInputFile(testInputFile);
DllLoader driver = DllLoader.LoadDll(languageDriver);
SystinEngine.ExecuteTestFile(fr.Instructions, ref driver);
return 0;
}
private static FileInfo Validate(string p)
{
if (p == null)
{
throw new ArgumentNullException("p");
}
if(p.Length == 0){
throw new ArgumentNullException("p");
}
FileInfo file = new FileInfo(p);
return file;
}
#endregion
}
}
|