Cysharp / ConsoleAppFramework

Zero Dependency, Zero Overhead, Zero Reflection, Zero Allocation, AOT Safe CLI Framework powered by C# Source Generator.
MIT License
1.66k stars 95 forks source link

Subcommands in Help print - Syntax review #129

Open BlackPhlox opened 4 months ago

BlackPhlox commented 4 months ago

Based on the discussion in #123. I have moved to using an app-based method to set the display of subcommands to :

app.SubcommandHelp(DisplayType.Default);

I want this PR to be an ongoing discussion to define all the possible cases in the test that should pass, before revising the generator. Input is very much appreciated.

I don't think it makes sense to move forward with #125 before this PR gets resolved.

DamianReeves commented 4 months ago

Not strictly concerning this change, but related. It would nice to expose a method that user code can call to show the help for a command. Currently I can't see how to do this without totally rebuilding the help.

BlackPhlox commented 4 months ago

Not strictly concerning this change, but related. It would nice to expose a method that user code can call to show the help for a command. Currently I can't see how to do this without totally rebuilding the help.

@DamianReeves where in user code are you thinking of?

Something like this? :

// Program.cs
var app = ConsoleApp.Create();
app.Add<TestCommand>("test");
app.Run(args);

string testHelpOutput = app.GetHelp("test");

or via Dependency Injection in a command?

patricktcoakley commented 6 days ago

Just bumping to see if this is still possible? I think both this and an exposed Help/Version method would be ideal.