Currently, APRS# prompts the user to optionally enter username and password, using default values if the user chooses to not enter any commands. While this is clear, it's a bit verbose and difficult for a user to call in a command line scripting scenario. The number of optional parameters will also grow as APRS# supports an increasing number of scenarios and configurations (user filters, sources, log files, etc.).
Because of this, many command line applications use parameters or flags. This would allow us to change our flow from:
where excluding either of those parameters could use the default value we have already been using.
It may also be nice to have the "short" version of the parameters, though this is less necessary. For example:
> aprsshar -c N0CALL -p -1
"Begin receiving..."
Eventually, this framework will expand to support receiving from different sources such as a hardware connector (that is a "TNC"), maybe decoding from a file or string passed om the command line or even sending via a TNC connection. Not to be implemented now but should be kept in mind for the future.
Implementation Notes
Though it's possible to do this by manually parsing the args string array in public static main(string[] args), we likely want to approach this in a more sustainable way. There are several libraries already around and I'm sure many of them would do the trick nicely.
One in particular that looks interesting is under development by the .NET folks already and is called System.CommandLine (GitHub repo, nuget.org listing). Since they support .NET Standard 2.0, we should be good to use them. It might be a good place to start investigating as it may become the new standard going forward. If there is a reason it won't work or that we should use something else, we should discuss and make a decision from there.
Acceptance Criteria
To consider this issue complete the following items must be completed and checked in:
[ ] Add code to set up the following commands
[ ] Some way to show help. The usual methods are one or all of --help, -h, -?. If it isn't too difficult, maybe all three. It should print out a description of APRS# with a link to our repository and a description of each of the commands added after this.
[ ] --callsign (and maybe -c) to specify a callsign with which to register to the server (same as we are doing now with callsign, just a new way of fetching it)
[ ] --password (and maybe -p) to specify a password (maybe this should fail if --callsign isn't set)
[ ] The command line should show appropriate errors if the values are incorrect (for example, I add --callsign but don't specify a callsign) or if the combination of parameters is incorrect (e.g. --password without --callsign) or missing (calling just aprssharp should show the help page and exit).
[ ] Add tests and ensure they're passing
[ ] Remove the current Console.WriteLine method of asking the user for input
Nice to have but not required:
[ ] Ability to specify which APRS-IS server to use. Might be nice. --server and a URL could be nice.
Description
Currently, APRS# prompts the user to optionally enter username and password, using default values if the user chooses to not enter any commands. While this is clear, it's a bit verbose and difficult for a user to call in a command line scripting scenario. The number of optional parameters will also grow as APRS# supports an increasing number of scenarios and configurations (user filters, sources, log files, etc.).
Because of this, many command line applications use parameters or flags. This would allow us to change our flow from:
to a single invocation:
where excluding either of those parameters could use the default value we have already been using.
It may also be nice to have the "short" version of the parameters, though this is less necessary. For example:
Eventually, this framework will expand to support receiving from different sources such as a hardware connector (that is a "TNC"), maybe decoding from a file or string passed om the command line or even sending via a TNC connection. Not to be implemented now but should be kept in mind for the future.
Implementation Notes
Though it's possible to do this by manually parsing the
args
string array inpublic static main(string[] args)
, we likely want to approach this in a more sustainable way. There are several libraries already around and I'm sure many of them would do the trick nicely.One in particular that looks interesting is under development by the .NET folks already and is called System.CommandLine (GitHub repo, nuget.org listing). Since they support .NET Standard 2.0, we should be good to use them. It might be a good place to start investigating as it may become the new standard going forward. If there is a reason it won't work or that we should use something else, we should discuss and make a decision from there.
Acceptance Criteria
To consider this issue complete the following items must be completed and checked in:
--help
,-h
,-?
. If it isn't too difficult, maybe all three. It should print out a description of APRS# with a link to our repository and a description of each of the commands added after this.--callsign
(and maybe-c
) to specify a callsign with which to register to the server (same as we are doing now with callsign, just a new way of fetching it)--password
(and maybe-p
) to specify a password (maybe this should fail if--callsign
isn't set)--callsign
but don't specify a callsign) or if the combination of parameters is incorrect (e.g.--password
without--callsign
) or missing (calling justaprssharp
should show the help page and exit).Console.WriteLine
method of asking the user for inputNice to have but not required:
--server
and a URL could be nice.