Interface ICommandlineParser
Interface for parsing command line arguments
Namespace: Ubiquity.CommandlineParsing
Assembly: Ubiquity.CommandlineParsing.dll
Syntax
public interface ICommandlineParser
Remarks
This interface allows for different underlying parsing engines, depending on the needs of an application. For example there is a monad parser available that uses the Sprache parser combinator library. However, if the app already has a full featured parser, like ANTLR, it may not make sense to pull in the dependencies for the Sprache parser and instead, just use the ANTLR version instead.
The parser accepts a superset of all valid command lines. That is, it parses and accepts without error all syntactically and semantically valid input AND some semantically invalid input. It is then up to the consuming application or binder to perform the final semantic evaluation. This helps keep the parser implementations generalized enough for re-use as-is while supporting a wide variety of command line styles without enforcing any one in particular.
Important
It is important to note that the result of the parse is intentionally not necessarily semantically valid for a given application. That is, the parser does not implement all the subtle rules of a particular use case. Instead it parses the fundamental syntax, and leaves the semantics to the consumer of the results. For example, '-a --all' would parse as two distinct options. It is up to the application or binder it uses to decide if that is an error. (They may represent distinct options or the '-a' may be a short form of '--all'. If they represent the same option, it is up to the application to decide if the multiple occurrences are valid or an error) This helps keep the parser implementation generally reusable and simplifies most applications to focusing on the task of validating the arguments instead of parsing them.
Methods
Parse(IEnumerable<String>) | Parse arguments list from platform provided list of args |