NuGet / Home

Repo for NuGet Client issues
Other
1.48k stars 251 forks source link

dotnet package search --interactive --format json (What should happen in this case?) #13164

Open Nigusu-Allehu opened 7 months ago

Nigusu-Allehu commented 7 months ago

NuGet Product(s) Involved

dotnet.exe

The Elevator Pitch

What happens in this case? Interactive requires stopping, but format only writes when the operation has finished.

Additional Context and Details

No response

nkolev92 commented 7 months ago

The scenario is the following:

Prerequisites:

Because you've never authenticated, you'd normally get an prompt on standard out, but given that you have --format, the operation tends to wait to write result, but normally in format json, you're expecting a json file to parse, but the auth prompt is not going to provide that

The 2 modes are not fully intuitive when combined.

zivkan commented 5 months ago

an option is also for nuget to write cred provider prompts to stderr, rather than stdout. Just for dotnet CLI commands that support json output, not for all NuGet commands. So, dotnet list package --format json in addition to dotnet package search --format json. While CI and other scripts might detect stderr output as being an error, given --interactive, anything automated isn't going to use --interactive.

It might not be trivial to implement, given NuGet's existing software architecture, but it's something that's technically possible, and I believe a "common" pattern for other apps where customers typically redirect stdout.