fclp / fluent-command-line-parser

A simple, strongly typed .NET C# command line parser library using a fluent easy to use interface
Other
530 stars 85 forks source link

Show dashes in help #100

Open robrich opened 6 years ago

robrich commented 6 years ago

Help doesn't make it obvious that the user needs to include dashes when passing options.

I was working with a novice user with one of my command-line apps. He passed in nothing, it correctly displayed the help:

b:big   This option makes it bigger
l:little  This option makes it smaller

(not the real options)

So he called myapp.exe b foo l bar and it happily did nothing.

Showing help like this would make it more obvious:

-b --big   This option makes it bigger
-l --little  This option makes it smaller

Would you accept a PR to change the help to this format?

InteXX commented 5 years ago

I found a temporary workaround for this:

Sub Main
  ...
  oParser.SetupHelp("?", "help").Callback(GetHelp(oParser.Options))
End Main

Public Function GetHelp(Options As List(Of ICommandLineOption)) As Action(Of String)
  Dim oBuilder As StringBuilder
  Dim oOption As ICommandLineOption
  Dim sUsage As String

  Return Sub(Usage)
           oBuilder = New StringBuilder
           oOption = Options.First

           oBuilder.AppendLine($"Backup [(/{oOption.ShortName} | /{oOption.LongName}):JobName]")
           oBuilder.AppendLine()
           oBuilder.AppendLine("This argument is optional. If it isn't provided, the configuration window is displayed.")

           sUsage = oBuilder.ToString

           MessageBox.Show(sUsage, "Usage", MessageBoxButtons.OK, MessageBoxIcon.None)
         End Sub
End Function