dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.64k stars 1.05k forks source link

Completion for dotnet add package should suggest package version #9334

Open svick opened 6 years ago

svick commented 6 years ago

Steps to reproduce

The NuGet autocomplete API supports suggesting possible versions for a package, e.g. https://api-v2v3search-0.nuget.org/autocomplete?id=Microsoft.CodeAnalysis&take=100. It would be nice if dotnet add package took advantage of this. E.g.:

dotnet add package Microsoft.CodeAnalysis -v <Tab>
1.0.0
1.0.1
1.1.0
1.1.1
1.2.0
1.2.1
1.2.2
1.3.0
1.3.1
1.3.2
2.0.0
2.1.0
2.2.0
2.3.0
2.3.1
2.3.2
2.4.0
2.6.0
2.6.1
2.7.0

Expected behavior

dotnet complete "dotnet add package PACKAGE -v " returns the list of versions for PACKAGE.

Actual behavior

dotnet complete "dotnet add package PACKAGE -v " returns empty result.

svick commented 6 years ago

As far as I can tell, the command line parser used by CLI lacks the capabilities required to support this, so I have opened an issue about adding that: https://github.com/dotnet/CliCommandLineParser/issues/103.

wli3 commented 6 years ago

for this issue specifically. the change is in dotnet complete (still in this repo). CLI currently do a rest api call to nuget to complete package name. It should do something similar. However, I am not sure there is an api from nuget to complete version

svick commented 6 years ago

@wli3

CLI currently do a rest api call to nuget to complete package name.

Yeah, I know. I currently have a PR out to switch it to a better API: https://github.com/dotnet/cli/pull/9171.

I am not sure there is an api from nuget to complete version

The autocomplete API can do that, that's why I included a link to it in the first post.

Specifically, URL like https://api-v2v3search-0.nuget.org/autocomplete?id=Microsoft.CodeAnalysis&take=100 gives you exactly what you need (formatting mine):

{
   "@context":{"@vocab":"http://schema.nuget.org/schema#"},
   "totalHits":1,
   "lastReopen":"2018-05-01T22:15:02.2667857Z",
   "index":"v3-lucene2-v2v3-20171018",
   "data":["1.0.0","1.0.1","1.1.0","1.1.1","1.2.0","1.2.1","1.2.2","1.3.0","1.3.1","1.3.2","2.0.0","2.1.0","2.2.0","2.3.0","2.3.1","2.3.2","2.4.0","2.6.0","2.6.1","2.7.0"]
}

What I don't know is how to make this work using the WithSuggestionsFrom API, which is why I opened https://github.com/dotnet/CliCommandLineParser/issues/103.

wli3 commented 6 years ago

@svick ah now I see. Thanks you for the explanation

rspaulino commented 4 years ago

@wli3 I notice this issues have been open since 2018 and the PR have been merge, when will this feature actually arrive to the cli? I'm a little confused.

wli3 commented 4 years ago

The feature is not in CLI. This issue is in the backlog. So there is no ETA for the fix.

rspaulino commented 4 years ago

@wli3 thanks for the clarifying