Table of Contents

Class Parser

Namespace
MASES.CLIParser
Assembly
MASES.CLIParser.dll

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

IReadOnlyList<IArgumentMetadata>

Settings

The settings in use

public Settings Settings { get; }

Property Value

Settings

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 IArgumentMetadata

IArgumentMetadata 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

settings Settings

The Settings to use or the default

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 string

Argument 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 IArgumentMetadataParsed

The IArgumentMetadataParsed to parse

Returns

IEnumerable<IArgumentMetadataParsed>

A list of IArgumentMetadataParsed

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

IEnumerable<IArgumentMetadataParsed>

A list of IArgumentMetadataParsed

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 int

Index 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 string

The 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 IArgumentMetadataParsed

The 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 int

Index 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 string

The 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

string

A string with help information

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 bool

Replace 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 IArgumentMetadataParsed

IArgumentMetadataParsed to parse

Returns

IEnumerable<IArgumentMetadataParsed>

A list of IArgumentMetadataParsed

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

IEnumerable<IArgumentMetadataParsed>

A list of IArgumentMetadataParsed

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

Returns

IEnumerable<IArgumentMetadataParsed>

A list of IArgumentMetadataParsed