Argument input and help cmd

This commit is contained in:
Dimitar Byalkov
2021-07-07 14:48:51 +03:00
parent b3e85c62e5
commit 19b7505f44
3 changed files with 32 additions and 4 deletions

View File

@@ -25,7 +25,7 @@ namespace BoerseDataConvert
public string ConvertToXml(Record record)
{
StringBuilder xmlRecord = new StringBuilder();
xmlRecord.Append($" <record id=”{count}”>\n");
xmlRecord.Append($" <record id=\"{count}\">\n");
foreach (var tagValue in record.TagsValues)
{
try

View File

@@ -15,8 +15,27 @@ namespace BoerseDataConvert
// -d directory or --dir directory
// -o directory or --output direcory
// -h - help
// Console.OutputEncoding = System.Text.Encoding.UTF8;
Console.WriteLine();
Reader reader = new Reader(@"E:\Downloads\TestData-2021_07_02", new string[1] { "subtype910.txt" });
if (args.Contains("-i") || args.Contains("--input"))
{
string zipfile = args[Array.IndexOf(args, "-i") + 1];
}
if (args.Contains("-d") || args.Contains("--directory"))
{
string inputDir = args[Array.IndexOf(args, "-d" + 1)];
}
if (args.Contains("-o") || args.Contains("--output"))
{
string outputDir = args[Array.IndexOf(args, "-o" + 1)];
}
if (args.Contains("-h") || args.Contains("--help"))
{
Help();
return;
}
// Reader reader = new Reader(@"E:\Downloads\TestData-2021_07_02", new string[1] { "subtype910.txt" });
Reader reader = new Reader(@"D:\Code\ИТ Кариера\Стаж\задача\TestData-2021_07_02", new string[1] { "subtype910.txt" });
RecordController a = new RecordController("");
while (true)
{
@@ -32,5 +51,14 @@ namespace BoerseDataConvert
}
}
static void Help()
{
Console.WriteLine("BoerseDataConvert v1.0.0");
Console.WriteLine("D. Delchev and D. Byalkov, 2021");
Console.WriteLine("---");
Console.WriteLine("-i <input zip file> or --input <input zip file>");
Console.WriteLine("-d <working directory> or --directory <working directory>");
Console.WriteLine("-o <output directory> or --output <output directory>");
}
}
}

View File

@@ -16,7 +16,7 @@ namespace BoerseDataConvert
public Reader(string adr, string[] filesNames)
{
fileInd = 0;
reader = new StreamReader($@"{adr}/{filesNames[fileInd]}", CodePagesEncodingProvider.Instance.GetEncoding(1252), true);
reader = new StreamReader($@"{adr}/{filesNames[fileInd]}", CodePagesEncodingProvider.Instance.GetEncoding(1252));
this.adr = adr;
this.filesNames = filesNames;
reader.ReadLine();
@@ -28,7 +28,7 @@ namespace BoerseDataConvert
{
fileInd++;
reader.Close();
reader = new StreamReader($@"{adr}/{filesNames[fileInd]}", CodePagesEncodingProvider.Instance.GetEncoding(1252), true);
reader = new StreamReader($@"{adr}/{filesNames[fileInd]}", CodePagesEncodingProvider.Instance.GetEncoding(1252));
RecordController.NextFile(filesNames[fileInd]);
s = reader.ReadLine();
s = reader.ReadLine();