Skip to content

Commit

Permalink
Improvements on DistroLauncher.
Browse files Browse the repository at this point in the history
  • Loading branch information
RezaT4795 committed Mar 18, 2022
1 parent 8503572 commit 6b9a386
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/WSLackwareLauncher/DistroLauncher/DistroLauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,8 @@ HRESULT InstallDistribution(bool createUser)
if (FAILED(hr)) {
return hr;
}

}



return hr;
}

Expand All @@ -75,7 +72,7 @@ HRESULT SetDefaultUser(std::wstring_view userName)
return hr;
}

int wmain(int argc, wchar_t const *argv[])
int wmain(int argc, wchar_t const* argv[])
{
// Update the title bar of the console window.
SetConsoleTitleW(DistributionInfo::WindowTitle.c_str());
Expand Down Expand Up @@ -110,7 +107,8 @@ int wmain(int argc, wchar_t const *argv[])
Helpers::PrintMessage(MSG_INSTALL_ALREADY_EXISTS);
}

} else {
}
else {
Helpers::PrintMessage(MSG_INSTALL_SUCCESS);
}

Expand All @@ -128,8 +126,9 @@ int wmain(int argc, wchar_t const *argv[])
Helpers::PromptForInput();
}

} else if ((arguments[0] == ARG_RUN) ||
(arguments[0] == ARG_RUN_C)) {
}
else if ((arguments[0] == ARG_RUN) ||
(arguments[0] == ARG_RUN_C)) {

std::wstring command;
for (size_t index = 1; index < arguments.size(); index += 1) {
Expand All @@ -139,7 +138,8 @@ int wmain(int argc, wchar_t const *argv[])

hr = g_wslApi.WslLaunchInteractive(command.c_str(), true, &exitCode);

} else if (arguments[0] == ARG_CONFIG) {
}
else if (arguments[0] == ARG_CONFIG) {
hr = E_INVALIDARG;
if (arguments.size() == 3) {
if (arguments[1] == ARG_CONFIG_DEFAULT_USER) {
Expand All @@ -151,7 +151,8 @@ int wmain(int argc, wchar_t const *argv[])
exitCode = 0;
}

} else {
}
else {
Helpers::PrintMessage(MSG_USAGE);
return exitCode;
}
Expand All @@ -162,7 +163,12 @@ int wmain(int argc, wchar_t const *argv[])
if (hr == HRESULT_FROM_WIN32(ERROR_LINUX_SUBSYSTEM_NOT_PRESENT)) {
Helpers::PrintMessage(MSG_MISSING_OPTIONAL_COMPONENT);

} else {
}
else if (hr == HCS_E_HYPERV_NOT_INSTALLED) {
Helpers::PrintMessage(MSG_ENABLE_VIRTUALIZATION);

}
else {
Helpers::PrintErrorMessage(hr);
}

Expand All @@ -172,4 +178,4 @@ int wmain(int argc, wchar_t const *argv[])
}

return SUCCEEDED(hr) ? exitCode : 1;
}
}
10 changes: 10 additions & 0 deletions src/WSLackwareLauncher/DistroLauncher/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,13 @@
//
#define MSG_INSTALL_ALREADY_EXISTS 0x000003F5L

//
// MessageId: MSG_ENABLE_VIRTUALIZATION
//
// MessageText:
//
// Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS.
// For information please visit https://aka.ms/enablevirtualization
//
#define MSG_ENABLE_VIRTUALIZATION 0x000003F6L

6 changes: 6 additions & 0 deletions src/WSLackwareLauncher/DistroLauncher/messages.mc
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,9 @@ Language=English
The distribution installation has become corrupted.
Please select Reset from App Settings or uninstall and reinstall the app.
.
MessageId=1014 SymbolicName=MSG_ENABLE_VIRTUALIZATION
Language=English
Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS.
For information please visit https://aka.ms/enablevirtualization
.

0 comments on commit 6b9a386

Please sign in to comment.