diff --git a/Spectre.Docs.Cli.Examples/DemoApps/CommandHierarchies/Main.cs b/Spectre.Docs.Cli.Examples/DemoApps/CommandHierarchies/Main.cs
index 0339958..37142fd 100644
--- a/Spectre.Docs.Cli.Examples/DemoApps/CommandHierarchies/Main.cs
+++ b/Spectre.Docs.Cli.Examples/DemoApps/CommandHierarchies/Main.cs
@@ -72,6 +72,13 @@ public class RemoteRemoveSettings : RemoteSettings
public string Name { get; init; } = string.Empty;
}
+///
+/// Settings for listing remotes.
+///
+public class RemoteListSettings : RemoteSettings
+{
+}
+
internal class RemoteAddCommand : Command
{
protected override int Execute(CommandContext context, RemoteAddSettings settings, CancellationToken cancellation)
@@ -94,9 +101,9 @@ protected override int Execute(CommandContext context, RemoteRemoveSettings sett
}
}
-internal class RemoteListCommand : Command
+internal class RemoteListCommand : Command
{
- protected override int Execute(CommandContext context, RemoteSettings settings, CancellationToken cancellation)
+ protected override int Execute(CommandContext context, RemoteListSettings settings, CancellationToken cancellation)
{
System.Console.WriteLine("Listing remotes...");
if (settings.Verbose)
diff --git a/Spectre.Docs/Content/cli/how-to/working-with-multiple-command-hierarchies.md b/Spectre.Docs/Content/cli/how-to/working-with-multiple-command-hierarchies.md
index 75d2c1c..077785e 100644
--- a/Spectre.Docs/Content/cli/how-to/working-with-multiple-command-hierarchies.md
+++ b/Spectre.Docs/Content/cli/how-to/working-with-multiple-command-hierarchies.md
@@ -15,7 +15,7 @@ A git-style CLI with nested `remote` subcommands—`add`, `remove`, and `list`
## Create a Command Branch
-Use `AddBranch("name", ...)` to define a parent command with nested subcommands:
+Use `AddBranch` to define a parent command with nested subcommands. Use the generic overload when you want shared settings/options for the branch:
```csharp:xmldocid,bodyonly
M:Spectre.Docs.Cli.Examples.DemoApps.CommandHierarchies.Demo.RunAsync(System.String[])
@@ -30,13 +30,16 @@ Define a base settings class for the branch, then inherit from it in subcommand
```csharp:xmldocid
T:Spectre.Docs.Cli.Examples.DemoApps.CommandHierarchies.RemoteSettings
T:Spectre.Docs.Cli.Examples.DemoApps.CommandHierarchies.RemoteAddSettings
+T:Spectre.Docs.Cli.Examples.DemoApps.CommandHierarchies.RemoteListSettings
```
-The `--verbose` flag is now available on all remote subcommands: `myapp remote add origin https://... --verbose`.
+The `--verbose` flag is now available on all remote subcommands, and can be specified either before or after the subcommand name: `myapp remote --verbose add origin https://...` or `myapp remote add origin https://... --verbose`.
+
+Rule: when you use `AddBranch`, each subcommand's settings type should inherit from `TSettings`. Even if a subcommand doesn't add any extra arguments/options (like `list`), give it a dedicated settings type (for example, `RemoteListSettings : RemoteSettings`).
## Nest Multiple Levels
-For complex CLIs, branches can contain other branches:
+For complex CLIs, branches can contain other branches (use the non-generic overload when you just want grouping):
```csharp
config.AddBranch("cloud", cloud =>
@@ -54,4 +57,4 @@ This creates deeply nested commands like `myapp cloud storage upload`.
## See Also
- - Basic command registration
-- - Settings class patterns
\ No newline at end of file
+- - Settings class patterns