Skip to content

Commit 447f763

Browse files
committed
R: move FindResultFor(Symbol) to ParseResult
1 parent a256d12 commit 447f763

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/System.CommandLine/Parsing/ParseResult.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,5 +166,14 @@ public T ValueForOption<T>(string alias)
166166

167167
public OptionResult? FindResultFor(IOption option) =>
168168
_rootCommandResult.FindResultFor(option);
169+
170+
public SymbolResult? FindResultFor(ISymbol symbol) =>
171+
symbol switch
172+
{
173+
IArgument argument => FindResultFor(argument),
174+
ICommand command => FindResultFor(command),
175+
IOption option => FindResultFor(option),
176+
_ => throw new ArgumentOutOfRangeException(nameof(symbol))
177+
};
169178
}
170179
}

src/System.CommandLine/Parsing/ParseResultExtensions.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ argument.Parents[0] is ICommand command &&
159159
builder.Append(">");
160160

161161
break;
162-
163162
}
164163

165164
if (includeArgumentName)
@@ -182,17 +181,6 @@ argument.Parents[0] is ICommand command &&
182181
}
183182
}
184183

185-
public static SymbolResult? FindResultFor(
186-
this ParseResult parseResult,
187-
ISymbol symbol) =>
188-
symbol switch
189-
{
190-
IArgument argument => parseResult.FindResultFor(argument),
191-
ICommand command => parseResult.FindResultFor(command),
192-
IOption option => parseResult.FindResultFor(option),
193-
_ => throw new ArgumentOutOfRangeException(nameof(symbol))
194-
};
195-
196184
public static bool HasOption(
197185
this ParseResult parseResult,
198186
IOption option)

0 commit comments

Comments
 (0)