Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Core/NetArgumentParser/Subcommands/ParserQuantum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,28 @@ public IEnumerable<ICommonOption> FindOptions(
return foundOptions.Concat(recursiveFoundOptions);
}

public bool FindFirstOptionByLongName(string longName, bool recursive, out ICommonOption? foundOption)
{
IEnumerable<ICommonOption> foundOptions = FindOptions(t => t.LongName == longName, recursive);
foundOption = foundOptions.FirstOrDefault();

return foundOption is not null;
}

public bool FindFirstValueOptionByLongName<T>(
string longName,
bool recursive,
out IValueOption<T>? foundOption)
{
IEnumerable<ICommonOption> foundOptions = FindOptions(
t => t.LongName == longName && t is IValueOption<T>,
recursive);

foundOption = foundOptions.FirstOrDefault() as IValueOption<T>;

return foundOption is not null;
}

protected virtual void AddDefaultOptions()
{
foreach (ParserQuantum quantum in _subcommands.Concat([this]))
Expand Down
2 changes: 1 addition & 1 deletion Documentation/ParserGenerationUsingAttributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ Using attributes in C# imposes a restriction on their argument types. An attribu
- `MultipleValueOption` choices.
- Custom after handing action and after value parsing action.

However, you can find the option using `FindOptions()` method and further configure it.
However, you can find the option using `FindOptions()`, `FindFirstOptionByLongName()`, or a similar method, and then configure it.

```cs
var generator = new ArgumentParserGenerator();
Expand Down
3 changes: 3 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ This is the TODO file where you can find some features and content that need to

## Features
- [ ] Come up with new features.
- [ ] Add mutually inclusive groups.
- [ ] Add the ability to sort options (by name, by weight, etc) in application description generator.
- [ ] Add XML documentation.