Class CommandLineParser
Represents the environment command line arguments
Inherited Members
Namespace: PayrollEngine.Client.Command
Assembly: PayrollEngine.Client.Core.dll
Syntax
public class CommandLineParser
Constructors
CommandLineParser(string[])
Represents the environment command line arguments
Declaration
public CommandLineParser(string[] arguments)
Parameters
| Type | Name | Description |
|---|---|---|
| string[] | arguments |
Properties
Arguments
Command line arguments
Declaration
public string[] Arguments { get; }
Property Value
| Type | Description |
|---|---|
| string[] |
Count
Get the command line arguments count
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int |
ParameterCount
Get the command line arguments count, excluding the implicit parameter at index 0
Declaration
public int ParameterCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Get(int, string, bool)
Gets the specified index, starting at 1
Declaration
public string Get(int index, string name = null, bool allowToggle = false)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The argument index |
| string | name | The argument name (default=null) |
| bool | allowToggle | Argument can be a toggle (default: false) |
Returns
| Type | Description |
|---|---|
| string | The argument value |
GetArguments()
Get all arguments.
Declaration
public string[] GetArguments()
Returns
| Type | Description |
|---|---|
| string[] |
GetByName(string)
Get argument by name
Declaration
public string GetByName(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The argument name (optional) |
Returns
| Type | Description |
|---|---|
| string | The argument value |
GetEnumToggle<T>(T)
Gets a toggle with fallback value
Declaration
public T GetEnumToggle<T>(T defaultValue) where T : struct, Enum
Parameters
| Type | Name | Description |
|---|---|---|
| T | defaultValue | The default value |
Returns
| Type | Description |
|---|---|
| T | The argument value |
Type Parameters
| Name | Description |
|---|---|
| T | The enum type |
GetEnum<T>(int, string)
Gets a mandatory enum argument
Declaration
public T GetEnum<T>(int index, string name = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The argument index |
| string | name | The argument name (optional) |
Returns
| Type | Description |
|---|---|
| T | The argument value |
Type Parameters
| Name | Description |
|---|---|
| T | The enum type |
GetEnum<T>(int, T, string)
Gets an enum argument
Declaration
public T GetEnum<T>(int index, T defaultValue, string name = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The argument index |
| T | defaultValue | The default value |
| string | name | The argument name (optional) |
Returns
| Type | Description |
|---|---|
| T | The argument value |
Type Parameters
| Name | Description |
|---|---|
| T | The enum type |
GetInt(int, int, string)
Gets an integer argument
Declaration
public int GetInt(int index, int defaultValue, string name = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The argument index |
| int | defaultValue | The default value |
| string | name | The argument name (optional) |
Returns
| Type | Description |
|---|---|
| int | The argument value |
GetInt(int, string)
Gets an integer argument
Declaration
public int? GetInt(int index, string name = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The argument index |
| string | name | The argument name (optional) |
Returns
| Type | Description |
|---|---|
| int? | The argument value |
GetMember(int, string, bool)
Gets the specified index, starting at 1
Declaration
public string GetMember(int index, string memberName = "", bool allowToggle = false)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The argument index |
| string | memberName | The caller name |
| bool | allowToggle | Argument can be a toggle |
Returns
| Type | Description |
|---|---|
| string | The argument value |
GetToggles()
Gets all toggle with fallback value
Declaration
public IEnumerable<string> GetToggles()
Returns
| Type | Description |
|---|---|
| IEnumerable<string> | The argument value |
IsValidOrder()
Determines whether the specified argument exists
Declaration
public bool IsValidOrder()
Returns
| Type | Description |
|---|---|
| bool | True if the specified toggle exists |
NewFromCommand(string)
New command line parser from command string
Declaration
public static CommandLineParser NewFromCommand(string command)
Parameters
| Type | Name | Description |
|---|---|---|
| string | command |
Returns
| Type | Description |
|---|---|
| CommandLineParser |
NewFromEnvironment()
New command line parser from environment command line arguments
Declaration
public static CommandLineParser NewFromEnvironment()
Returns
| Type | Description |
|---|---|
| CommandLineParser |
TestMultipleToggles(IEnumerable<Type>)
Test for multiple toggles
Declaration
public Type TestMultipleToggles(IEnumerable<Type> enumTypes)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<Type> | enumTypes | The supported enum types |
Returns
| Type | Description |
|---|---|
| Type | The failed type |
TestUnknownToggles(IEnumerable<Type>)
Test for unknown toggle arguments
Declaration
public string TestUnknownToggles(IEnumerable<Type> enumTypes)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<Type> | enumTypes | The supported enum types |
Returns
| Type | Description |
|---|---|
| string | The unknown argument |