# Summary

Class: | WireMock.Net.StandAlone.SimpleCommandLineParser
Assembly: | WireMock.Net.StandAlone
File(s): | C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net.StandAlone\SimpleCommandLineParser.cs
Covered lines: | 0
Uncovered lines: | 54
Coverable lines: | 54
Total lines: | 83
Line coverage: | 0%
Branch coverage: | 0%

# Metrics

Method | Cyclomatic complexity | NPath complexity | Sequence coverage | Branch coverage
--- | --- | --- | --- | ---
Parse(...) | 0 | 0 | 0 | 0
Contains(...) | 0 | 0 | 0 | 0
GetValues(...) | 0 | 0 | 0 | 0
GetValue(...) | 0 | 0 | 0 | 0
GetBoolValue(...) | 0 | 0 | 0 | 0
GetIntValue(...) | 0 | 0 | 0 | 0
GetStringValue(...) | 0 | 0 | 0 | 0

# File(s)

## C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net.StandAlone\SimpleCommandLineParser.cs

| # | Line |  | Line coverage
--- | --- | --- | --- | ---
|  | `1` |  | `using System;`
|  | `2` |  | `using System.Collections.Generic;`
|  | `3` |  | `using System.Linq;`
|  | `4` |  | ``
|  | `5` |  | `namespace WireMock.Net.StandAlone`
|  | `6` |  | `{`
|  | `7` |  | `// Based on http://blog.gauffin.org/2014/12/simple-command-line-parser/`
|  | `8` |  | `internal class SimpleCommandLineParser`
|  | `9` |  | `{`
| 0 | `10` |  | `private IDictionary<string, string[]> Arguments { get; } = new Dictionary<string, string[]>();`
|  | `11` |  | ``
|  | `12` |  | `public void Parse(string[] args)`
| 0 | `13` |  | `{`
| 0 | `14` |  | `string currentName = null;`
|  | `15` |  | ``
| 0 | `16` |  | `var values = new List<string>();`
| 0 | `17` |  | `foreach (string arg in args)`
| 0 | `18` |  | `{`
| 0 | `19` |  | `if (arg.StartsWith("--"))`
| 0 | `20` |  | `{`
| 0 | `21` |  | `if (!string.IsNullOrEmpty(currentName))`
| 0 | `22` |  | `{`
| 0 | `23` |  | `Arguments[currentName] = values.ToArray();`
| 0 | `24` |  | `}`
|  | `25` |  | ``
| 0 | `26` |  | `values.Clear();`
| 0 | `27` |  | `currentName = arg.Substring(2);`
| 0 | `28` |  | `}`
| 0 | `29` |  | `else if (string.IsNullOrEmpty(currentName))`
| 0 | `30` |  | `{`
| 0 | `31` |  | `Arguments[arg] = new string[0];`
| 0 | `32` |  | `}`
|  | `33` |  | `else`
| 0 | `34` |  | `{`
| 0 | `35` |  | `values.Add(arg);`
| 0 | `36` |  | `}`
| 0 | `37` |  | `}`
|  | `38` |  | ``
| 0 | `39` |  | `if (!string.IsNullOrEmpty(currentName))`
| 0 | `40` |  | `{`
| 0 | `41` |  | `Arguments[currentName] = values.ToArray();`
| 0 | `42` |  | `}`
| 0 | `43` |  | `}`
|  | `44` |  | ``
|  | `45` |  | `public bool Contains(string name)`
| 0 | `46` |  | `{`
| 0 | `47` |  | `return Arguments.ContainsKey(name);`
| 0 | `48` |  | `}`
|  | `49` |  | ``
|  | `50` |  | `public string[] GetValues(string name, string[] defaultValue = null)`
| 0 | `51` |  | `{`
| 0 | `52` |  | `return Contains(name) ? Arguments[name] : defaultValue;`
| 0 | `53` |  | `}`
|  | `54` |  | ``
|  | `55` |  | `public T GetValue<T>(string name, Func<string[], T> func, T defaultValue = default(T))`
| 0 | `56` |  | `{`
| 0 | `57` |  | `return Contains(name) ? func(Arguments[name]) : defaultValue;`
| 0 | `58` |  | `}`
|  | `59` |  | ``
|  | `60` |  | `public bool GetBoolValue(string name, bool defaultValue = false)`
| 0 | `61` |  | `{`
| 0 | `62` |  | `return GetValue(name, values =>`
| 0 | `63` |  | `{`
| 0 | `64` |  | `string value = values.FirstOrDefault();`
| 0 | `65` |  | `return !string.IsNullOrEmpty(value) ? bool.Parse(value) : defaultValue;`
| 0 | `66` |  | `}, defaultValue);`
| 0 | `67` |  | `}`
|  | `68` |  | ``
|  | `69` |  | `public int? GetIntValue(string name, int? defaultValue = null)`
| 0 | `70` |  | `{`
| 0 | `71` |  | `return GetValue(name, values =>`
| 0 | `72` |  | `{`
| 0 | `73` |  | `string value = values.FirstOrDefault();`
| 0 | `74` |  | `return !string.IsNullOrEmpty(value) ? int.Parse(value) : defaultValue;`
| 0 | `75` |  | `}, defaultValue);`
| 0 | `76` |  | `}`
|  | `77` |  | ``
|  | `78` |  | `public string GetStringValue(string name, string defaultValue = null)`
| 0 | `79` |  | `{`
| 0 | `80` |  | `return GetValue(name, values => values.FirstOrDefault() ?? defaultValue, defaultValue);`
| 0 | `81` |  | `}`
|  | `82` |  | `}`
|  | `83` |  | `}`

# Methods/Properties

Arguments()
Parse(System.String[])
Contains(System.String)
GetValues(System.String,System.String[])
GetValue(System.String,System.Func`2<System.String[],T>,T)
GetBoolValue(System.String,System.Boolean)
GetIntValue(System.String,System.Nullable`1<System.Int32>)
GetStringValue(System.String,System.String)