Skip to content

Commit

Permalink
Fix the knackered formating from the PR merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Whewell committed Jun 25, 2023
1 parent 2bd7a2a commit 703bc7d
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions opensky-to-basestation/OptionsParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,16 @@ public static Options Parse(string[] args)
{
var result = new Options();

if (args.Length == 0)
{
if(args.Length == 0) {
Usage(null);
}

for (var i = 0; i < args.Length; ++i)
{
for(var i = 0;i < args.Length;++i) {
var arg = (args[i] ?? "");
var normalisedArg = arg.ToLower();
var nextArg = i + 1 < args.Length ? args[i + 1] : null;

switch (normalisedArg)
{
switch(normalisedArg) {
case "/?":
case "-help":
case "-?":
Expand Down Expand Up @@ -111,8 +108,7 @@ public static Options Parse(string[] args)

private static Command ParseCommand(Options options, Command command)
{
if (options.Command != Command.None)
{
if(options.Command != Command.None) {
Usage($"Cannot specify both {options.Command} and {command} commands");
}

Expand All @@ -121,8 +117,7 @@ private static Command ParseCommand(Options options, Command command)

private static string UseNextArg(string arg, string nextArg, ref int argIndex)
{
if (String.IsNullOrWhiteSpace(nextArg))
{
if(String.IsNullOrWhiteSpace(nextArg)) {
Usage($"{arg} argument missing");
}
++argIndex;
Expand All @@ -132,21 +127,17 @@ private static string UseNextArg(string arg, string nextArg, ref int argIndex)

private static T ParseEnum<T>(string arg)
{
try
{
try {
return (T)Enum.Parse(typeof(T), arg ?? "", ignoreCase: true);
}
catch (ArgumentException)
{
} catch(ArgumentException) {
Usage($"{arg} is not a recognised {typeof(T).Name} value");
throw;
}
}

private static int ParseInt(string arg)
{
if (!int.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
{
if(!int.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) {
Usage($"{arg} is not an integer");
}

Expand All @@ -155,8 +146,7 @@ private static int ParseInt(string arg)

private static double ParseDouble(string arg)
{
if (!double.TryParse(arg, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
{
if(!double.TryParse(arg, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) {
Usage($"{arg} is not a floating point value (remember to use . for the decimal point)");
}

Expand Down Expand Up @@ -191,8 +181,7 @@ public static void Usage(string message)
Console.WriteLine($"DIAGNOSTICS");
Console.WriteLine($" -jsonFileName <filename> The full path to a file that the OpenSky JSON will be saved to [{defaults.OpenSkyJsonFileName}]");

if (!String.IsNullOrEmpty(message))
{
if(!String.IsNullOrEmpty(message)) {
Console.WriteLine();
Console.WriteLine(message);
}
Expand Down

0 comments on commit 703bc7d

Please sign in to comment.