Skip to content

Inappropriate typo suggestion for argument of option #2010

Open

Description

@KalleOlaviNiemitalo

In --option=argument syntax, if the argument is not accepted by the option, then typo correction can suggest replacing the argument with a different option. That should not happen when they are connected by an equals sign.

Demo

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.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;

return new RootCommand().Invoke(args);
$ dotnet run -- --version=h-
'h-' was not matched. Did you mean one of the following?
-h
1.0.0

Activity

  1. KalleOlaviNiemitalo commented on Jan 2, 2023

    @KalleOlaviNiemitalo
    Author

    A secondary bug here is that the version middleware outputs the version even after typo correction has notified the user about the invalid syntax.

  2. jonsequitur commented on Feb 23, 2023

    @jonsequitur
    Contributor

    Related: #2064

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions