Skip to content

Commit 1ea7d48

Browse files
Clarify all kinds of error messages for better resolution;
Give 2 examples of usage in help text;
1 parent 33402e5 commit 1ea7d48

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Diff for: XtractQuery/Program.cs

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.IO;
33
using System.Linq;
4+
using System.Reflection;
45
using XtractQuery.Interfaces;
56
using XtractQuery.Options;
67
using XtractQuery.Parsers;
@@ -27,19 +28,19 @@ static void Main(string[] args)
2728

2829
if (!arguments.Operation.Exists)
2930
{
30-
Console.WriteLine("Specify a valid operation");
31+
Console.WriteLine("No operation mode was given. Specify an operation mode by using the -o argument.");
3132
return;
3233
}
3334

3435
if (!arguments.QueryType.Exists)
3536
{
36-
Console.WriteLine("Specify a valid type");
37+
Console.WriteLine("No query type was given. Specify a query type by using the -t argument.");
3738
return;
3839
}
3940

4041
if (!arguments.QueryFile.Exists)
4142
{
42-
Console.WriteLine("Specify a file");
43+
Console.WriteLine("No file to process was specified. Specify a file by using the -f argument.");
4344
return;
4445
}
4546

@@ -49,19 +50,19 @@ static void Main(string[] args)
4950

5051
if (operation != "e" && operation != "c")
5152
{
52-
Console.WriteLine("Specify a valid operation");
53+
Console.WriteLine($"The operation mode '{operation}' is not valid. Use -h to see a list of valid operation modes.");
5354
return;
5455
}
5556

5657
if (type != "xq32" && type != "xseq")
5758
{
58-
Console.WriteLine("Specifiy a valid type");
59+
Console.WriteLine($"The query type '{type}' is not valid. Use -h to see a list of valid query types.");
5960
return;
6061
}
6162

6263
if (!File.Exists(file))
6364
{
64-
Console.WriteLine($"File {file} does not exist");
65+
Console.WriteLine($"File '{Path.GetFullPath(file)}' was not found.");
6566
return;
6667
}
6768

@@ -142,6 +143,10 @@ private static void PrintHelp()
142143
Console.WriteLine(" -t, --type\t\tThe type of file given");
143144
Console.WriteLine(" Valid types are: xq32, xseq");
144145
Console.WriteLine(" -f, --file\t\tThe file to process");
146+
Console.WriteLine();
147+
Console.WriteLine("Example usage:");
148+
Console.WriteLine($"\tExtract a xq32 query to human readable text: {Assembly.GetExecutingAssembly().Location} -o e -t xq32 -f [file]");
149+
Console.WriteLine($"\tCreate a xq32 query from human readable text: {Assembly.GetExecutingAssembly().Location} -o c -t xq32 -f [file]");
145150
}
146151
}
147152
}

0 commit comments

Comments
 (0)