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

Fix --x-json for vcpkg search and vcpkg find port. #351

Merged
merged 2 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/vcpkg/commands.find.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,8 @@ namespace
}

constexpr StringLiteral OPTION_FULLDESC = "x-full-desc"; // TODO: This should find a better home, eventually
constexpr StringLiteral OPTION_JSON = "x-json";

constexpr std::array<CommandSwitch, 2> FindSwitches = {{
{OPTION_FULLDESC, "Do not truncate long text"},
{OPTION_JSON, "(experimental) List libraries in JSON format"},
}};
constexpr std::array<CommandSwitch, 1> FindSwitches = {{{OPTION_FULLDESC, "Do not truncate long text"}}};

const CommandStructure FindCommandStructure = {
Strings::format("Searches for the indicated artifact or port. With no parameter after 'artifact' or 'port', "
Expand Down Expand Up @@ -208,7 +204,7 @@ namespace vcpkg::Commands
{
const ParsedArguments options = args.parse_arguments(FindCommandStructure);
const bool full_description = Util::Sets::contains(options.switches, OPTION_FULLDESC);
const bool enable_json = Util::Sets::contains(options.switches, OPTION_JSON);
const bool enable_json = args.json.value_or(false);
auto&& selector = args.command_arguments[0];
Optional<StringView> filter;
if (args.command_arguments.size() == 2)
Expand All @@ -220,12 +216,12 @@ namespace vcpkg::Commands
{
if (full_description)
{
print2(Color::warning, "--%s has no effect on find artifact", OPTION_FULLDESC);
print2(Color::warning, "--%s has no effect on find artifact\n", OPTION_FULLDESC);
}

if (enable_json)
{
print2(Color::warning, "--%s has no effect on find artifact", OPTION_JSON);
print2(Color::warning, "--x-json has no effect on find artifact\n");
}

perform_find_artifact_and_exit(paths, filter);
Expand Down
9 changes: 2 additions & 7 deletions src/vcpkg/commands.search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@
namespace vcpkg::Commands
{
static constexpr StringLiteral OPTION_FULLDESC = "x-full-desc"; // TODO: This should find a better home, eventually
static constexpr StringLiteral OPTION_JSON = "x-json";

static constexpr std::array<CommandSwitch, 2> SearchSwitches = {{
{OPTION_FULLDESC, "Do not truncate long text"},
{OPTION_JSON, "(experimental) List libraries in JSON format"},
}};
static constexpr std::array<CommandSwitch, 1> SearchSwitches = {{{OPTION_FULLDESC, "Do not truncate long text"}}};

const CommandStructure SearchCommandStructure = {
Strings::format(
Expand All @@ -30,13 +26,12 @@ namespace vcpkg::Commands
{
const ParsedArguments options = args.parse_arguments(SearchCommandStructure);
const bool full_description = Util::Sets::contains(options.switches, OPTION_FULLDESC);
const bool enable_json = Util::Sets::contains(options.switches, OPTION_JSON);
Optional<StringView> filter;
if (!args.command_arguments.empty())
{
filter = StringView{args.command_arguments[0]};
}

perform_find_port_and_exit(paths, full_description, enable_json, filter, args.overlay_ports);
perform_find_port_and_exit(paths, full_description, args.json.value_or(false), filter, args.overlay_ports);
}
}