aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/commands_create.cpp
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2016-09-23 17:07:01 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2016-09-23 17:07:01 -0700
commitc7a7d062a750bce13a9db3fa8af5018d38554565 (patch)
tree6a4dfbd07e6e18cc2b01e3d587f046333f94d14b /toolsrc/src/commands_create.cpp
parent6cc29c1f84ae61fabfd3a60200c2ef1fabb50eac (diff)
downloadvcpkg-c7a7d062a750bce13a9db3fa8af5018d38554565.tar.gz
vcpkg-c7a7d062a750bce13a9db3fa8af5018d38554565.zip
Fix `vcpkg create` to not parse all arguments as package specs
Diffstat (limited to 'toolsrc/src/commands_create.cpp')
-rw-r--r--toolsrc/src/commands_create.cpp38
1 files changed, 24 insertions, 14 deletions
diff --git a/toolsrc/src/commands_create.cpp b/toolsrc/src/commands_create.cpp
index 73d163af8..c08842d65 100644
--- a/toolsrc/src/commands_create.cpp
+++ b/toolsrc/src/commands_create.cpp
@@ -7,29 +7,39 @@ namespace vcpkg
void create_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet)
{
args.check_max_args(3);
- package_spec spec = args.parse_all_arguments_as_package_specs(default_target_triplet).at(0);
if (args.command_arguments.size() < 2)
{
System::println(System::color::error, "Error: create requires the archive's URL as the second argument.");
print_usage();
exit(EXIT_FAILURE);
}
- Environment::ensure_utilities_on_path(paths);
- // Space OR define the FILENAME with proper spacing
- std::wstring custom_filename = L" ";
- if (args.command_arguments.size() >= 3)
+ expected<package_spec> current_spec = package_spec::from_string(args.command_arguments[0], default_target_triplet);
+ if (const package_spec* spec = current_spec.get())
{
- custom_filename = Strings::format(L" -DFILENAME=%s ", Strings::utf8_to_utf16(args.command_arguments.at(2)));
- }
+ Environment::ensure_utilities_on_path(paths);
+
+ // Space OR define the FILENAME with proper spacing
+ std::wstring custom_filename = L" ";
+ if (args.command_arguments.size() >= 3)
+ {
+ custom_filename = Strings::format(LR"( -DFILENAME="%s" )", Strings::utf8_to_utf16(args.command_arguments.at(2)));
+ }
- const std::wstring cmdline = Strings::format(LR"(cmake -DCMD=SCAFFOLD -DPORT=%s -DTARGET_TRIPLET=%s -DURL=%s%s-P "%s")",
- Strings::utf8_to_utf16(spec.name),
- Strings::utf8_to_utf16(spec.target_triplet.value),
- Strings::utf8_to_utf16(args.command_arguments.at(1)),
- custom_filename,
- paths.ports_cmake.generic_wstring());
+ const std::wstring cmdline = Strings::format(LR"(cmake -DCMD=SCAFFOLD -DPORT=%s -DTARGET_TRIPLET=%s -DURL=%s%s-P "%s")",
+ Strings::utf8_to_utf16(spec->name),
+ Strings::utf8_to_utf16(spec->target_triplet.value),
+ Strings::utf8_to_utf16(args.command_arguments.at(1)),
+ custom_filename,
+ paths.ports_cmake.generic_wstring());
- exit(System::cmd_execute(cmdline));
+ exit(System::cmd_execute(cmdline));
+ }
+ else
+ {
+ System::println(System::color::error, "Error: %s: %s", current_spec.error_code().message(), args.command_arguments[0]);
+ print_example(Strings::format("%s zlib:x64-windows", args.command).c_str());
+ exit(EXIT_FAILURE);
+ }
}
}