vcpkg/toolsrc/src/commands_help.cpp

92 lines
3.6 KiB
C++
Raw Normal View History

2017-01-28 04:49:09 +08:00
#include "pch.h"
2017-04-28 09:08:52 +08:00
2016-09-19 11:50:08 +08:00
#include "vcpkg_Commands.h"
#include "vcpkg_System.h"
namespace vcpkg::Commands::Help
2016-09-19 11:50:08 +08:00
{
2017-04-04 07:29:11 +08:00
void help_topic_valid_triplet(const VcpkgPaths& paths)
{
System::println("Available architecture triplets:");
for (auto&& path : paths.get_filesystem().get_files_non_recursive(paths.triplets))
{
System::println(" %s", path.stem().filename().string());
}
}
void print_usage()
{
System::println(
"Commands:\n"
" vcpkg search [pat] Search for packages available to be built\n"
" vcpkg install <pkg>... Install a package\n"
" vcpkg remove <pkg>... Uninstall a package\n"
" vcpkg remove --outdated Uninstall all out-of-date packages\n"
" vcpkg list List installed packages\n"
" vcpkg update Display list of packages for updating\n"
" vcpkg hash <file> [alg] Hash a file by specific algorithm, default SHA512\n"
"\n"
"%s" // Integration help
"\n"
" vcpkg edit <pkg> Open up a port for editing (uses %%EDITOR%%, default 'code')\n"
" vcpkg import <pkg> Import a pre-built library\n"
" vcpkg create <pkg> <url>\n"
" [archivename] Create a new package\n"
" vcpkg owns <pat> Search for files in installed packages\n"
" vcpkg cache List cached compiled packages\n"
" vcpkg version Display version information\n"
" vcpkg contact Display contact information to send feedback\n"
"\n"
//"internal commands:\n"
//" --check-build-deps <controlfile>\n"
//" --create-binary-control <controlfile>\n"
//"\n"
"Options:\n"
" --triplet <t> Specify the target architecture triplet.\n"
" (default: %%VCPKG_DEFAULT_TRIPLET%%, see 'vcpkg help triplet')\n"
"\n"
" --vcpkg-root <path> Specify the vcpkg root directory\n"
" (default: %%VCPKG_ROOT%%)\n"
"\n"
2017-04-28 09:08:52 +08:00
"For more help (including examples) see the accompanying README.md.",
Integrate::INTEGRATE_COMMAND_HELPSTRING);
}
std::string create_example_string(const std::string& command_and_arguments)
{
std::string cs = Strings::format("Example:\n"
2017-04-28 09:08:52 +08:00
" vcpkg %s",
command_and_arguments);
return cs;
}
void print_example(const std::string& command_and_arguments)
{
System::println(create_example_string(command_and_arguments));
}
2017-04-04 07:29:11 +08:00
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
2016-09-19 11:50:08 +08:00
{
args.check_max_arg_count(1);
args.check_and_get_optional_command_arguments({});
2016-09-19 11:50:08 +08:00
if (args.command_arguments.empty())
{
print_usage();
Checks::exit_success(VCPKG_LINE_INFO);
2016-09-19 11:50:08 +08:00
}
const auto& topic = args.command_arguments[0];
if (topic == "triplet")
{
help_topic_valid_triplet(paths);
2016-09-19 11:50:08 +08:00
}
else
{
2017-04-04 07:31:00 +08:00
System::println(System::Color::error, "Error: unknown topic %s", topic);
print_usage();
Checks::exit_fail(VCPKG_LINE_INFO);
2016-09-19 11:50:08 +08:00
}
Checks::exit_success(VCPKG_LINE_INFO);
2016-09-19 11:50:08 +08:00
}
}