Skip to content

Commit

Permalink
Merge pull request #4 from z80andrew/development
Browse files Browse the repository at this point in the history
Handle case where no parameters are passed to executable
  • Loading branch information
z80andrew authored Apr 22, 2019
2 parents 51bc51a + cf5c563 commit 902667a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions SerialDisk/SerialDisk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ public static void Main(string[] args)
.Build()
.Bind(applicationSettings);

applicationSettings.LocalDirectoryName = ParseLocalDirectoryPath(applicationSettings, args.Last());
if (args.Any())
{
applicationSettings.LocalDirectoryName = ParseLocalDirectoryPath(applicationSettings, args.Last());
}
}

catch (Exception parameterException)
Expand All @@ -121,7 +124,7 @@ public static void Main(string[] args)
return;
}

if ((bool)args[0].ToLowerInvariant().StartsWith("--h"))
if (args.Any() && (bool)args[0].ToLowerInvariant().StartsWith("--h"))
{
PrintUsage(applicationSettings);
return;
Expand All @@ -130,6 +133,9 @@ public static void Main(string[] args)
if (String.IsNullOrEmpty(applicationSettings.LocalDirectoryName)
|| !Directory.Exists(applicationSettings.LocalDirectoryName)) throw new Exception("Local directory name invalid.");

DirectoryInfo localDirectoryInfo = new DirectoryInfo(applicationSettings.LocalDirectoryName);
applicationSettings.LocalDirectoryName = localDirectoryInfo.FullName;

#endregion

Logger logger = new Logger(applicationSettings.LoggingLevel, applicationSettings.LogFileName);
Expand Down

0 comments on commit 902667a

Please sign in to comment.