Class SdkCommandLine
- Namespace
- RDCore.SDK.Server.Configuration
- Assembly
- RDCore.SDK.dll
Parses a platform application's command line into SdkAppCommandLineArgs.
public static class SdkCommandLine
- Inheritance
-
SdkCommandLine
- Inherited Members
Remarks
Every platform application parses the same arguments the same way, and every one of them has to tell
a command line that asked a question apart from one that configures a run: the parser answers
--help and --version by writing the text itself, then reports the request as a parse
error and hands back a default instance. Reading that instance as configuration is what made
rdc --help print its help, then a stack trace underneath it, and exit -1.
Methods
Parse(string[])
Parses args as SdkAppCommandLineArgs.
public static SdkAppCommandLineArgs Parse(string[] args)
Parameters
argsstring[]The command-line arguments as received.
Returns
- SdkAppCommandLineArgs
The parsed arguments.
TryAnswer(string[], out int)
Answers args when it is not a command line to run with: one that asked only
for the help or version text, or one the parser could not make sense of at all.
public static bool TryAnswer(string[] args, out int exitCode)
Parameters
argsstring[]The command-line arguments as received.
exitCodeintThe process exit code:
0for a question that was answered,-1for a command line that could not be parsed. Meaningless when this returnsfalse.
Returns
- bool
trueif the parser has written its answer and there is nothing to run;falseifargsconfigures a run, which the caller goes on to Parse(string[]).
Remarks
Writing the text, or the list of what it did not understand, is the parser's own side effect of
being asked. It reports a help or version request as a parse error because there is
nothing left for it to parse, not because anything is wrong with what it was given — so an
application has to ask this before it decides it has failed. Either way what the parser hands back
is a default instance, and reading that as configuration is what turned both cases into a
NullReferenceException printed under the parser's own output.