Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
yakovypg committed Jan 27, 2025
1 parent 90c691a commit 8961aec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions Documentation/OptionalArguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ Additional group:
```

## Mutual Exclusion
If you add options to the mutually exclusive group, **NetArgumentParser** will make sure that only one of the arguments in this group was present on the command line. Note that currently mutually exclusive groups don't have title and description (it will not be displayed in the help output). Moreover, you cannot add options to the option set using mutually exclusive group. This group is intended only to mark options that are already added.
If you add options to the mutually exclusive group, **NetArgumentParser** will make sure that only one of the arguments in this group was present on the command line. Note that title and description of mutually exclusive group will not be displayed in the help output. Moreover, you cannot add options to the option set using mutually exclusive group. This group is intended only to mark options that are already added.

You can create mutually exclusive group using `AddMutuallyExclusiveOptionGroup()` method of the `ArgumentParser` class. Options can be added to this group by passing them to method `AddMutuallyExclusiveOptionGroup()` or by calling method `AddOptions()` of the created group.

Expand All @@ -270,8 +270,10 @@ var nickOption = new ValueOption<string>("nick", afterValueParsingAction: t => n
var parser = new ArgumentParser();
parser.AddOptions(options);

MutuallyExclusiveOptionGroup<ICommonOption> group =
parser.AddMutuallyExclusiveOptionGroup([nameOption, nickOption]);
MutuallyExclusiveOptionGroup<ICommonOption> group = parser.AddMutuallyExclusiveOptionGroup(
"group",
"description",
[nameOption, nickOption]);

parser.Parse(new string[] { "--name", "John" }); // name: John
parser.Parse(new string[] { "--nick", "mr.john" }); // nick: mr.john
Expand Down
2 changes: 1 addition & 1 deletion Documentation/Subcommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Subcommand subcommand = parser.AddSubcommand("name", "description");
subcommand.AddOptions(new FlagOption("verbose", afterHandlingAction: () => verbose = true));
subcommand.AddConverters(new ValueConverter<int>(Convert.ToInt32));

OptionGroup<ICommonOption> subcommandGroup = subcommand.AddOptionGroup("group", string.Empty);
OptionGroup<ICommonOption> subcommandGroup = subcommand.AddOptionGroup("group", "description");
subcommandGroup.AddOptions(new FlagOption("debug", afterHandlingAction: () => debug = true));
```

Expand Down

0 comments on commit 8961aec

Please sign in to comment.