-
Notifications
You must be signed in to change notification settings - Fork 0
Command Line Tool
The repository includes the Flight Recorder Manager, a command line management tool that includes facilities to do the following:
- Manage database users
- Import data into the database from CSV format files
- Export data from the database in CSV format
- Apply database migrations
- Look up data using the external APIs
To use the tool, first edit the "appsettings.json" file in the "FlightRecorder.Manager" folder and set the location where the database is stored:
{
"ConnectionStrings": {
"FlightRecorderDB": "Data Source=<path>/flightrecorder.db"
}
}
To use the external API integration from the command line tool, make sure the API key for the external APIs has been configured, as per the details in the section on the Application Configuration File.
Open a terminal window, change to your working copy of the FlightRecorder.Manager project and enter the following commands to build the project and show its "usage" message:
dotnet run
The output from the "run" command should look similar to the following:
Flight Recorder Database Management 1.5.0.0
Usage:
[1] FlightRecorder.Manager add username password
[2] FlightRecorder.Manager setpassword username password
[3] FlightRecorder.Manager delete username
[4] FlightRecorder.Manager import airports|sightings csv_file_path
[5] FlightRecorder.Manager export sightings|airports|airlines|locations|manufacturers|flights csv_file_path
[6] FlightRecorder.Manager update
[7] FlightRecorder.Manager lookup flight|airport|aircraft
Note that all the examples, below, assume the application is being run from the working copy of the FlightRecorder.Manager project.
The section on using a SQLite database includes instructions on how to add users to the database.
Changing an existing user's password and deleting an existing user are similar, but require the command line arguments listed in the output, above.
Import of data from CSV-format files is covered in the section on CSV Import.
Data can be exported using the syntax shown in the example output, above:
- The "export" option is specified
- It requires two further arguments:
- The data to be exported, specified as one of the options listed in the example output, above
- The path to a CSV file to export the data to
For example, the following will export all sightings in the database:
dotnet run -- export sightings my-sightings.csv
The output will look something like this:
Flight Recorder Database Management 1.5.0.0
Exporting sightings to my-sightings.csv
To apply the latest migrations to the database,
dotnet run -- update
The output should be similar to the following:
Flight Recorder Database Management 1.5.0.0
Applied the latest database migrations
This will also create the database if it doesn't already exist.
The command line tool implements the ability to look-up data using the external APIs:
- Flights, given a flight number
- Airports, given an airport IATA code
- Aircraft, given a registration number
The following provides an example of how to look up a flight using the APIs via the command line tool:
dotnet run -- lookup flight LS803
The output should look similar to the following:
Flight Recorder Database Management 1.5.0.0
Looking up flight with identifier LS803
Flight LS803:
Departure Airport = MAN
Destination Airport = BCN
Airline = Jet2
The following provides an example of how to look up a flight using the APIs via the command line tool:
dotnet run -- lookup airport LCA
The output should look similar to the following:
Flight Recorder Database Management 1.5.0.0
Looking up airport with identifier LCA
Airport LCA:
Airport = Larnarca Larnaca
Country = Cyprus
The following provides an example of how to look up a flight using the APIs via the command line tool:
dotnet run -- lookup aircraft G-JZHG
The output should look similar to the following:
Flight Recorder Database Management 1.5.0.0
Looking up aircraft with identifier G-JZHG
Registration G-JZHG:
Registration = G-JZHG
24-bit ICAO Address = 407031
Serial Number = 28388
Registration Date = 2016-05-06
Model = B738
Model Code = B737-85P
Type = Boeing 737-800
Production Line = Boeing 737 NG
Age = 8
Manufacturer = Boeing