Class Parser
Public entry point for the parser
public class Parser
- Inheritance
-
Parser
- Inherited Members
Properties
Arguments
Available IArgumentMetadata for parsing
public IReadOnlyList<IArgumentMetadata> Arguments { get; }
Property Value
Settings
The settings in use
public Settings Settings { get; }
Property Value
UnparsedArgs
The arguments in command-line not parsed, i.e. the possible extra arguments to be used from the application for other scopes
public string[] UnparsedArgs { get; }
Property Value
- string[]
Methods
Add(IArgumentMetadata)
Adds metadata
to the argument to be parsed from Parse(string[])
public void Add(IArgumentMetadata metadata)
Parameters
metadata
IArgumentMetadataIArgumentMetadata to be added
Add(IEnumerable<IArgumentMetadata>)
Adds metadata
to the argument to be parsed from Parse(string[])
public void Add(IEnumerable<IArgumentMetadata> metadatas)
Parameters
metadatas
IEnumerable<IArgumentMetadata>
CreateInstance(Settings)
Creates a new instance of Parser
public static Parser CreateInstance(Settings settings = null)
Parameters
Returns
- Parser
The newly created instance
Exist(IEnumerable<IArgumentMetadataParsed>, string)
Check the args
for existing name
public bool Exist(IEnumerable<IArgumentMetadataParsed> args, string name)
Parameters
args
IEnumerable<IArgumentMetadataParsed>Arguments to test using the list prepared using Parse(string[])
name
stringArgument name to search
Returns
- bool
true if the the argument with
name
name exist
Exists(IEnumerable<IArgumentMetadataParsed>)
Filter the args
for existing IArgumentMetadataParsed
public IEnumerable<IArgumentMetadataParsed> Exists(IEnumerable<IArgumentMetadataParsed> args)
Parameters
args
IEnumerable<IArgumentMetadataParsed>Arguments to test using the list prepared using Parse(string[])
Returns
- IEnumerable<IArgumentMetadataParsed>
A filtered list of IArgumentMetadataParsed
FromFile(IArgumentMetadataParsed)
Convert the IArgumentMetadataParsed file argument (i.e. IsFile is true) and return the converted arguments
public IEnumerable<IArgumentMetadataParsed> FromFile(IArgumentMetadataParsed arg)
Parameters
arg
IArgumentMetadataParsedThe IArgumentMetadataParsed to parse
Returns
FromFile(IEnumerable<IArgumentMetadataParsed>)
Convert the ensemble of IArgumentMetadataParsed searching file argument (i.e. IsFile is true) and return the converted arguments
public IEnumerable<IArgumentMetadataParsed> FromFile(IEnumerable<IArgumentMetadataParsed> args)
Parameters
args
IEnumerable<IArgumentMetadataParsed>An ensemble of IArgumentMetadataParsed to parse
Returns
Get(IEnumerable<IArgumentMetadataParsed>, int)
Return the IArgumentMetadataParsed at index
public IArgumentMetadataParsed Get(IEnumerable<IArgumentMetadataParsed> args, int index)
Parameters
args
IEnumerable<IArgumentMetadataParsed>An ensemble of IArgumentMetadataParsed to parse
index
intIndex to get
Returns
- IArgumentMetadataParsed
The selected IArgumentMetadataParsed
Get(IEnumerable<IArgumentMetadataParsed>, string)
Return the IArgumentMetadataParsed at name
public IArgumentMetadataParsed Get(IEnumerable<IArgumentMetadataParsed> args, string name)
Parameters
args
IEnumerable<IArgumentMetadataParsed>An ensemble of IArgumentMetadataParsed to parse
name
stringThe argument name, or short name, to get
Returns
- IArgumentMetadataParsed
The selected IArgumentMetadataParsed
Get<T>(IArgumentMetadataParsed)
Return the value from IArgumentMetadataParsed
public T Get<T>(IArgumentMetadataParsed arg)
Parameters
arg
IArgumentMetadataParsedThe IArgumentMetadataParsed to use to get value
Returns
- T
The value from IArgumentMetadataParsed
Type Parameters
T
The Type to use to retrieve value
Get<T>(IEnumerable<IArgumentMetadataParsed>, int)
Return the value of the IArgumentMetadataParsed ensemble at index
public T Get<T>(IEnumerable<IArgumentMetadataParsed> args, int index)
Parameters
args
IEnumerable<IArgumentMetadataParsed>An ensemble of IArgumentMetadataParsed to parse
index
intIndex to get
Returns
- T
The value from IArgumentMetadataParsed
Type Parameters
T
Get<T>(IEnumerable<IArgumentMetadataParsed>, string)
Return the value of the IArgumentMetadataParsed ensemble at name
public T Get<T>(IEnumerable<IArgumentMetadataParsed> args, string name)
Parameters
args
IEnumerable<IArgumentMetadataParsed>An ensemble of IArgumentMetadataParsed to parse
name
stringThe argument name, or short name, to get
Returns
- T
The value from IArgumentMetadataParsed
Type Parameters
T
HelpInfo(int?)
Returns the help information
public string HelpInfo(int? width = null)
Parameters
width
int?The width of the help to write
Returns
NotExists(IEnumerable<IArgumentMetadataParsed>)
Filter the args
for non existing IArgumentMetadataParsed
public IEnumerable<IArgumentMetadataParsed> NotExists(IEnumerable<IArgumentMetadataParsed> args)
Parameters
args
IEnumerable<IArgumentMetadataParsed>Arguments to test using the list prepared using Parse(string[])
Returns
- IEnumerable<IArgumentMetadataParsed>
A filtered list of IArgumentMetadataParsed
Override(IEnumerable<IArgumentMetadataParsed>, IEnumerable<IArgumentMetadataParsed>, bool)
Overrides values in destination
with values found in source
public IEnumerable<IArgumentMetadataParsed> Override(IEnumerable<IArgumentMetadataParsed> destination, IEnumerable<IArgumentMetadataParsed> source, bool rawReplace = false)
Parameters
destination
IEnumerable<IArgumentMetadataParsed>An ensemble of IArgumentMetadataParsed
source
IEnumerable<IArgumentMetadataParsed>An ensemble of IArgumentMetadataParsed
rawReplace
boolReplace destionation without check if argument exist in the source
Returns
- IEnumerable<IArgumentMetadataParsed>
The updated
destination
PaddingFromArguments()
Returns the padding calculated on argument length
public int PaddingFromArguments()
Returns
- int
The calculated length
Parse(IArgumentMetadataParsed)
Parse the IArgumentMetadataParsed if it represent a file argument (i.e. IsFile is true.)
public IEnumerable<IArgumentMetadataParsed> Parse(IArgumentMetadataParsed arg)
Parameters
arg
IArgumentMetadataParsedIArgumentMetadataParsed to parse
Returns
Parse(string[])
Parse the arguments and return a list of parsed IArgumentMetadataParsed
public IEnumerable<IArgumentMetadataParsed> Parse(string[] args)
Parameters
args
string[]Arguments to parse using the list prepared using Add(IArgumentMetadata)
Returns
RemoveFile(IEnumerable<IArgumentMetadataParsed>)
Return the IArgumentMetadataParsed without any accurrence of file argument (i.e. IsFile is true)
public IEnumerable<IArgumentMetadataParsed> RemoveFile(IEnumerable<IArgumentMetadataParsed> args)
Parameters
args
IEnumerable<IArgumentMetadataParsed>An ensemble of IArgumentMetadataParsed to check