Open
Description
In the help output, the Usage section shows Argument.Name, but the Arguments section shows Argument.HelpName. I think this is inconsistent and they should both use Argument.HelpName if set, so that Argument.Name would be culture-invariant and usable for System.CommandLine.NamingConventionBinder. #1891 (comment)
Demo
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
</ItemGroup>
</Project>
using System.CommandLine;
using System.IO;
var command = new RootCommand()
{
new Argument<FileInfo>(name: "inputfile")
{
HelpName = "inputfile.log",
},
};
return await command.InvokeAsync(args);
$ dotnet run
Required argument missing for command: 'ArgumentHelpDemo'.
Description:
Usage:
ArgumentHelpDemo <inputfile> [options]
Arguments:
<inputfile.log>
Options:
--version Show version information
-?, -h, --help Show help and usage information
Current implementation
Usage section:
command-line-api/src/System.CommandLine/Help/HelpBuilder.cs
Lines 296 to 304 in 209b724
Arguments section:
command-line-api/src/System.CommandLine/Help/HelpBuilder.Default.cs
Lines 73 to 87 in 209b724