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

[Feature Request] If No Package is installed and --x-json is specified, vcpkg list should be empty #13637

Closed
pratikpc opened this issue Sep 21, 2020 · 5 comments · Fixed by #13667
Assignees
Labels
category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed

Comments

@pratikpc
Copy link
Contributor

pratikpc commented Sep 21, 2020


Is your feature request related to a problem? Please describe.
A bit of an annoyance
I was writing an app of sorts that more tightly integrates vcpkg and CMake
During that, for obvious reasons, I had to access vcpkg list
So as I was developing an app, I used vcpkg list --x-json

When packages are Installed, output is
{
...blah blah blah
Useful info
}

When nothing is installed
Output is
No packages are installed. Did you mean search?
Proposed solution
Show output as {} (an Empty Object)

Describe alternatives you've considered
On my side, I am checking for an Exception from JSON.parse currently

Additional context
Not really
It's also experimental so unstable behaviour is both fair and expected

Edit:-

Fixing This

The place to fix this would be

if (installed_ipv.empty())

Out here if JSON Mode is enabled, it should output {}

Should I create a PR?

I can help out here

        if (installed_ipv.empty())
        {
            if(args.output_json())
                     System::print2("{}");
            else
                     System::print2("No packages are installed. Did you mean `search`?\n");
            Checks::exit_success(VCPKG_LINE_INFO);
        }
@PhoebeHui PhoebeHui added the category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed label Sep 22, 2020
@PhoebeHui
Copy link
Contributor

The original message may be useful for users, however, show output as {} (an Empty Object) also make sense, @strega-nil, could you help confirm this issue?

@strega-nil
Copy link
Contributor

This makes sense to me, although I'd do System::print2(Json::stringify(Json::Object(), {})).

@pratikpc
Copy link
Contributor Author

Yeah that would be the better method

Sorry

@strega-nil
Copy link
Contributor

Do you want to open a PR?

pratikpc added a commit to pratikpc/vcpkg that referenced this issue Sep 22, 2020
Thanks to @strega-nil for recommending using Json::stringify over my initial idea of simply printing an empty object

Closes microsoft#13637
@pratikpc
Copy link
Contributor Author

@strega-nil just opened a PR
Thanks for the help!!!

ras0219-msft pushed a commit that referenced this issue Sep 24, 2020
…3667)

Thanks to @strega-nil for recommending using Json::stringify over my initial idea of simply printing an empty object

Closes #13637
strega-nil pushed a commit to strega-nil/vcpkg that referenced this issue May 5, 2021
…crosoft#13667)

Thanks to @strega-nil for recommending using Json::stringify over my initial idea of simply printing an empty object

Closes microsoft#13637
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants