Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add help option to list --help output #104

Closed
sfoslund opened this issue Jan 6, 2020 · 6 comments · Fixed by #166
Closed

Add help option to list --help output #104

sfoslund opened this issue Jan 6, 2020 · 6 comments · Fixed by #166
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@sfoslund
Copy link
Member

sfoslund commented Jan 6, 2020

From manual testers: On Windows

Run "dotnet-core-uninstall list": it does not have the option "-h|--help", but using "dotnet-core-uninstall list --help" can work well.

GetImage (1)

@sfoslund sfoslund added bug Something isn't working good first issue Good for newcomers labels Mar 31, 2020
@NikiforovAll
Copy link
Contributor

I've investigated this issue. It looks like there is nothing wrong with the source code but rather System.CommandLine.Experimental being outdated.

using System;
using System.CommandLine;
using System.CommandLine.Builder;
using System.CommandLine.Invocation;

class Program
{
    static void Main()
    {
        var root = new RootCommand("test-description");
        root.Handler = CommandHandler.Create(() => { });
        var UninstallCommandParser = new CommandLineBuilder(root)
                    .UseDefaults()
                    .UseVersionOption() // this is redundant
                    .Build();

        UninstallCommandParser.Invoke(Environment.GetCommandLineArgs());
    }
}
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <AssemblyName>dotnet-core-uninstall</AssemblyName>
    <OutputType>Exe</OutputType>
    <RuntimeIdentifiers>win-x86;osx-x64</RuntimeIdentifiers>
    <SignAssembly>true</SignAssembly>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <PropertyGroup>
    <LangVersion>preview</LangVersion>
    <RootNamespace>Microsoft.DotNet.Tools.Uninstall</RootNamespace>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="System.CommandLine.Experimental" Version="0.3.0-alpha.*" />
    <PackageReference Include="System.CommandLine.Rendering" Version="0.3.0-alpha.19573.2" />
  </ItemGroup>
</Project>
root ➜ /demo $ .dotnet/dotnet run -- -h
dotnet-core-uninstall:
  test-description

Usage:
  dotnet-core-uninstall [options]

Options:
  --version    Display version information

E.g.

  <ItemGroup>
    <PackageReference Include="System.CommandLine.Experimental" Version="2.0.0-beta1.*" />
    <PackageReference Include="System.CommandLine.Rendering" Version="0.3.0-alpha.19573.2" />
  </ItemGroup>

image

@sfoslund
Copy link
Member Author

@NikiforovAll thanks for looking into this! If you want to make a PR to update I would be happy to review, otherwise I'll fix this in our next release.

@NikiforovAll
Copy link
Contributor

I would be glad to contribute!

@NikiforovAll
Copy link
Contributor

I plan to upgrade the System.CommandLine package:

-   <PackageReference Include="System.CommandLine.Experimental" Version="0.3.0-alpha.19573.2" />
+   <PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20574.7" />

It will lead to the next changes:

.\dotnet-core-uninstall.exe whatif -h
dry-run:
  Display .NET Core SDKs and Runtimes that will be removed.

Usage:
  dotnet-core-uninstall dry-run [options] [<VERSION>...]

Arguments:
  <VERSION>    The specified version to uninstall. You may list several versions. Response files are
               supported.

Options:
  --all                          Remove all .NET Core SDKs or Runtimes. (*)
  --all-below <VERSION>          Remove .NET Core SDKs or Runtimes below the specified version. The
                                 specified version will remain. (*)
  --all-but <VERSIONS>           Remove .NET Core SDKs or Runtimes, except those specified. (*)
  --all-but-latest               Remove .NET Core SDKs or Runtimes, except the one highest version. (*)
  --all-lower-patches            Remove .NET Core SDKs or Runtimes superseded by higher patches.
                                 Protects global.json. (*)
  --all-previews                 Remove .NET Core SDKs or Runtimes marked as previews. (*)
  --all-previews-but-latest      Remove .NET Core SDKs or Runtimes marked as previews, except the one
                                 highest preview. (*)
  --aspnet-runtime               Remove ASP.NET Core Runtimes only.
  --force                        Force removal of versions that might be used by Visual Studio.
  --hosting-bundle               Remove .NET Core Runtime & Hosting Bundles only.
  --major-minor <MAJOR_MINOR>    Remove .NET Core SDKs or Runtimes that match the specified
                                 `major.minor` version.
  --runtime                      Remove .NET Core Runtimes only.
  --sdk                          Remove .NET Core SDKs only.
  -v, --verbosity <LEVEL>        Set the verbosity level. Allowed values are q[uiet], m[inimal],
                                 n[ormal], d[etailed], and diag[nostic].
  --x64                          Can be used with --sdk, --runtime and --aspnet-runtime to remove x64.
  --x86                          Can be used with --sdk, --runtime and --aspnet-runtime to remove x86.
+  -?, -h, --help                 Show help and usage information

(*) By default, SDKs and Runtimes that have a high probability of being used by Visual Studio are not removed. To remove these, specify them individually or use --force. If removing SDKs or Runtimes causes issues with your installation of Visual Studio, run "Repair". SDKs and Runtimes are available for download at aka.ms/dotnet-core-download.

Regarding the --version option. It is expected behavior for subcommand to hide it. Please see https://github.com/dotnet/command-line-api/blob/main/src/System.CommandLine.Tests/VersionOptionTests.cs#L110 for more details.

@NikiforovAll
Copy link
Contributor

I'm sorry for inconvenience, but I won't have spare time for that in nearest future.

@sfoslund
Copy link
Member Author

I'm sorry for inconvenience, but I won't have spare time for that in nearest future.

No problem, I can take over the PR, thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants