|
81 | 81 | { |
82 | 82 | bool _optionsFirst; |
83 | 83 | bool _lastOptionsFirst; |
84 | | - string _commandLine; |
85 | | - string _lastCommandLine; |
86 | | - string _input; |
87 | | - string _lastInput; |
88 | | - string _output; |
89 | | - IDictionary<string, ArgValue> _args; |
90 | | - List<Node> _nodes; |
| 84 | + string _commandLine = string.Empty; |
| 85 | + string? _lastCommandLine; |
| 86 | + string? _input; |
| 87 | + string? _lastInput; |
| 88 | + string? _output; |
| 89 | + IDictionary<string, ArgValue>? _args; |
| 90 | + List<Node>? _nodes; |
91 | 91 | bool _error; |
92 | 92 | TimeSpan? _ms; |
93 | 93 | ElementReference _inputTextArea; |
@@ -145,7 +145,7 @@ Options: |
145 | 145 | _error = false; |
146 | 146 | _ms = null; |
147 | 147 |
|
148 | | - if (_input.Length == 0) |
| 148 | + if (_input is null or { Length: 0 }) |
149 | 149 | return; |
150 | 150 |
|
151 | 151 | var sw = Stopwatch.StartNew(); |
@@ -174,15 +174,15 @@ Options: |
174 | 174 | _output = sb.ToString(); |
175 | 175 |
|
176 | 176 | var docopt = new Docopt(); |
177 | | - var argv = _commandLine.Split((char[])null, StringSplitOptions.RemoveEmptyEntries); |
| 177 | + var argv = _commandLine.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries); |
178 | 178 | _nodes = Docopt.Internal |
179 | 179 | .GetNodes(_input, |
180 | 180 | (name, value) => new Node(name, value.Kind, 0, ArgValue.None), |
181 | 181 | (name, value) => new Node(name, value.IsStringList ? ArgValueKind.StringList : ArgValueKind.String, 0, ArgValue.None), |
182 | 182 | (name, _, _, _, value) => new Node(name, value.Kind, 0, ArgValue.None)) |
183 | 183 | .GroupBy(e => e.Name, e => e, (_, g) => new Node(g.First().Name, g.First().ValueKind, g.Count(), ArgValue.None)) |
184 | 184 | .ToList(); |
185 | | - _args = Docopt.Internal.Apply(docopt, _input, argv.AsEnumerable(), help: false, version: null, optionsFirst: _optionsFirst, exit: false); |
| 185 | + _args = Docopt.Internal.Apply(docopt, _input, argv.AsEnumerable(), help: false, version: null, optionsFirst: _optionsFirst, exit: false)!; |
186 | 186 | _nodes = _nodes.Select(n => new Node(n.Name, n.ValueKind, n.Count, _args.TryGetValue(n.Name, out var v) ? v : ArgValue.None)).ToList(); |
187 | 187 | _ms = sw.Elapsed; |
188 | 188 | } |
|
0 commit comments