Cysharp / ConsoleAppFramework

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

Implement command alias only for methods #97

Closed roumcha closed 11 months ago

roumcha commented 1 year ago

Problems

CommandAttribute has a constructor with multiple names (hereinafter called aliases), but it still has some problems. I guess that's the reason it's not officially introduced in readme.md.

  1. Aliases are shown twice in command helps (related to #96)
  2. Aliases doesn't work for classes
  3. If [2] above got solved, command help messages would be hard to read.
An example for [3] code: ```csharp [Command(new[] {"class1", "class2"})] class App : ConsoleAppBase { [Command(new[] { "command1", "command2" }, "desc")] public void Sample() { Console.WriteLine("Hello!"); } } ``` The help text for the code above would be: ```text class1, class2 command1, command2 desc ``` It's hard to see which is the parent's name and which is the method's at a glance.

What this PR will do

To solve [1] and [3], this PR will:

$ myapp.exe command-name --help 
Usage: command-name

Print "Hello, world!"

Options:
  ()

Aliases: command-alias-1, command-alias-2

What this PR won't do:

roumcha commented 1 year ago

The diff is very large because ConsoleAppEngine.cs had a lot of LF, and I accidentally changed them all into CRLF... Would it be better to recreate my commits?

github-actions[bot] commented 1 year ago

This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days.