|
|
|
@ -30,14 +30,15 @@ namespace Configuration
|
|
|
|
|
var outputFileName = new FileInfo(args.Last());
|
|
|
|
|
|
|
|
|
|
// Remove last file-name arg, to get a more consistent array
|
|
|
|
|
args = args.SkipLast(1).ToArray();
|
|
|
|
|
var strippedArgs = args.SkipLast(1).ToArray();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string[] givenFlags = args.Where((value, index) => index % 2 == 0).ToArray();
|
|
|
|
|
string[] givenFilePaths = args.Where((value, index) => index % 2 != 0).ToArray();
|
|
|
|
|
string[] givenFlags = strippedArgs.Where((value, index) => index % 2 == 0).ToArray();
|
|
|
|
|
string[] givenFilePaths = strippedArgs.Where((value, index) => index % 2 != 0).ToArray();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Assert only a single 'd' was passed
|
|
|
|
|
if ( givenFlags.Length == 1 && givenFlags[0].Equals("-d") ) {
|
|
|
|
|
string[] filesInDirectory = Directory.GetFiles(givenFilePaths[0]);
|
|
|
|
|
return new DemoApplicationConfiguration {
|
|
|
|
@ -45,6 +46,7 @@ namespace Configuration
|
|
|
|
|
JsonFilesInfo = filesInDirectory.Select(name => new FileInfo(name)).ToArray(),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
// Assert only '-f' were passed
|
|
|
|
|
else if (givenFlags.All((string flag) => flag.Equals("-f"))) {
|
|
|
|
|
return new DemoApplicationConfiguration {
|
|
|
|
|
OutputFile = outputFileName,
|
|
|
|
@ -52,12 +54,11 @@ namespace Configuration
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
throw new DemoApplicationConfigurationException("Must have either 1 flag that is '-d', of all flags must be '-f");
|
|
|
|
|
throw new DemoApplicationConfigurationException("Must have either 1 flag that is '-d', or all flags must be '-f");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (System.Exception e)
|
|
|
|
|
} catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Something else went wrong");
|
|
|
|
|
Console.WriteLine("Something went wrong");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|