Skip to content

Commit

Permalink
Merge pull request #13 from davewalker5/BSR-24-Add-CLI-Arguments-Parser
Browse files Browse the repository at this point in the history
Added command line parser for specifying arguments
  • Loading branch information
davewalker5 committed Aug 27, 2023
2 parents 3125148 + ef6415a commit 403cd1b
Show file tree
Hide file tree
Showing 17 changed files with 523 additions and 32 deletions.
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,20 @@
### Configuration File
- The appsettings.json file in the console application project contains the following keys for controlling the application:

| Section | Key | Purpose |
| --- | --- | --- |
| ApplicationSettings | Host | Host the reader connects to for reading messages |
| ApplicationSettings | Port | Port the reader connects to for reading messages |
| ApplicationSettings | TimeToRecent | Threshold, in ms, after the most recent message at which an aircraft is considered "recent" (see states, below) |
| ApplicationSettings | TimeToStale | Threshold, in ms, after the most recent message at which an aircraft is considered "stale" (see states, below) |
| ApplicationSettings | TimeToRemoval | Threshold, in ms, after the most recent message at which an aircraft is removed from tracking (see states, below) |
| ApplicationSettings | LogFile | Path and name of the log file |
| ApplicationSettings | EnableSqlWriter | Set to true to enable the SQL writer or false to disable it |
| ApplicationSettings | WriterInterval | Interval, in ms, at which the writer writes batches of changes from the queue to the database |
| ApplicationSettings | WriterBatchSize | Maximum number of changes to consider on each WriterInterval |
| ConnectionStrings | BaseStationReaderDB | SQLite connection string for the database |
| Section | Key | Command Line | Short Name | Purpose |
| --- | --- | --- | --- | --- |
| ApplicationSettings | Host | --host | -h | Host the reader connects to for reading messages |
| ApplicationSettings | Port | --port | -p | Port the reader connects to for reading messages |
| ApplicationSettings | TimeToRecent | --recent | -r | Threshold, in ms, after the most recent message at which an aircraft is considered "recent" (see states, below) |
| ApplicationSettings | TimeToStale | --stale | -s | Threshold, in ms, after the most recent message at which an aircraft is considered "stale" (see states, below) |
| ApplicationSettings | TimeToRemoval | --remove | -x | Threshold, in ms, after the most recent message at which an aircraft is removed from tracking (see states, below) |
| ApplicationSettings | LogFile | --log-file | -l | Path and name of the log file |
| ApplicationSettings | EnableSqlWriter | --enable-sql-writer | -w | Set to true to enable the SQL writer or false to disable it |
| ApplicationSettings | WriterInterval | --writer-interval | -i | Interval, in ms, at which the writer writes batches of changes from the queue to the database |
| ApplicationSettings | WriterBatchSize | --writer-batch-size | -b | Maximum number of changes to consider on each WriterInterval |
| ConnectionStrings | BaseStationReaderDB | - | - | SQLite connection string for the database |

- Values may also be passed using the indicated command line arguments, in which case the values are first read from the configuration file and then any values specified on the command line are then applied

## Aircraft Tracking

Expand Down
4 changes: 2 additions & 2 deletions src/BaseStationReader.Data/BaseStationReader.Data.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>BaseStationReader.Data</PackageId>
<PackageVersion>1.12.0.0</PackageVersion>
<PackageVersion>1.13.0.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2023</Copyright>
<Owners>Dave Walker</Owners>
Expand All @@ -17,7 +17,7 @@
<PackageProjectUrl>https://github.com/davewalker5/ADS-B-BaseStationReader</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>1.12.0.0</ReleaseVersion>
<ReleaseVersion>1.13.0.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>BaseStationReader.Entities</PackageId>
<PackageVersion>1.12.0.0</PackageVersion>
<PackageVersion>1.13.0.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2023</Copyright>
<Owners>Dave Walker</Owners>
Expand All @@ -17,7 +17,7 @@
<PackageProjectUrl>https://github.com/davewalker5/ADS-B-BaseStationReader</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>1.12.0.0</ReleaseVersion>
<ReleaseVersion>1.13.0.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
16 changes: 16 additions & 0 deletions src/BaseStationReader.Entities/Config/CommandLineOption.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Diagnostics.CodeAnalysis;

namespace BaseStationReader.Entities.Config
{
[ExcludeFromCodeCoverage]
public class CommandLineOption
{
public CommandLineOptionType OptionType { get; set; }
public bool Mandatory { get; set; } = false;
public string Name { get; set; } = "";
public string ShortName { get; set; } = "";
public string Description { get; set; } = "";
public int MinimumNumberOfValues { get; set; } = 1;
public int MaximumNumberOfValues { get; set; } = 1;
}
}
15 changes: 15 additions & 0 deletions src/BaseStationReader.Entities/Config/CommandLineOptionType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace BaseStationReader.Entities.Config
{
public enum CommandLineOptionType
{
Host,
Port,
TimeToRecent,
TimeToStale,
TimeToRemoval,
LogFile,
EnableSqlWriter,
WriterInterval,
WriterBatchSize
}
}
11 changes: 11 additions & 0 deletions src/BaseStationReader.Entities/Config/CommandLineOptionValue.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Diagnostics.CodeAnalysis;

namespace BaseStationReader.Entities.Config
{
[ExcludeFromCodeCoverage]
public class CommandLineOptionValue
{
public CommandLineOption? Option { get; set; }
public List<string> Values { get; private set; } = new List<string>();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;

namespace BaseStationReader.Entities.Exceptions
{
[Serializable]
[ExcludeFromCodeCoverage]
public class MalformedCommandLineException : Exception
{
public MalformedCommandLineException()
{
}

public MalformedCommandLineException(string message) : base(message)
{
}

public MalformedCommandLineException(string message, Exception inner) : base(message, inner)
{
}

protected MalformedCommandLineException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext)
{
}

public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;

namespace BaseStationReader.Entities.Exceptions
{
[Serializable]
[ExcludeFromCodeCoverage]
public class MissingMandatoryOptionException : Exception
{
public MissingMandatoryOptionException()
{
}

public MissingMandatoryOptionException(string message) : base(message)
{
}

public MissingMandatoryOptionException(string message, Exception inner) : base(message, inner)
{
}

protected MissingMandatoryOptionException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext)
{
}

public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
}
}
}
31 changes: 31 additions & 0 deletions src/BaseStationReader.Entities/Exceptions/TooFewValuesException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;

namespace BaseStationReader.Entities.Exceptions
{
[Serializable]
[ExcludeFromCodeCoverage]
public class TooFewValuesException : Exception
{
public TooFewValuesException()
{
}

public TooFewValuesException(string message) : base(message)
{
}

public TooFewValuesException(string message, Exception inner) : base(message, inner)
{
}

protected TooFewValuesException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext)
{
}

public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace BaseStationReader.Entities.Exceptions
{
[Serializable]
[ExcludeFromCodeCoverage]
public class TooManyValuesException : Exception
{
public TooManyValuesException()
{
}

public TooManyValuesException(string message) : base(message)
{
}

public TooManyValuesException(string message, Exception inner) : base(message, inner)
{
}

protected TooManyValuesException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext)
{
}

public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;

namespace BaseStationReader.Entities.Exceptions
{
[Serializable]
[ExcludeFromCodeCoverage]
public class UnrecognisedCommandLineOptionException : Exception
{
public UnrecognisedCommandLineOptionException()
{
}

public UnrecognisedCommandLineOptionException(string message) : base(message)
{
}

public UnrecognisedCommandLineOptionException(string message, Exception inner) : base(message, inner)
{
}

protected UnrecognisedCommandLineOptionException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext)
{
}

public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
}
}
}
4 changes: 2 additions & 2 deletions src/BaseStationReader.Logic/BaseStationReader.Logic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>BaseStationReader.Logic</PackageId>
<PackageVersion>1.12.0.0</PackageVersion>
<PackageVersion>1.13.0.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2023</Copyright>
<Owners>Dave Walker</Owners>
Expand All @@ -17,7 +17,7 @@
<PackageProjectUrl>https://github.com/davewalker5/ADS-B-BaseStationReader</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>1.12.0.0</ReleaseVersion>
<ReleaseVersion>1.13.0.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 403cd1b

Please sign in to comment.