whoop, we pass the commandline from the peasant, to the monarch, and then back!
This commit is contained in:
parent
36539cfa47
commit
27ace16652
|
@ -8,6 +8,10 @@ using namespace winrt::Windows::Foundation;
|
|||
|
||||
namespace winrt::Microsoft::Terminal::Remoting::implementation
|
||||
{
|
||||
// If you try to move this into the header, you will experience P A I N
|
||||
// It must be defined after CommandlineArgs.g.cpp, otherwise the compiler
|
||||
// will give you just the most impossible tmplate errors to try and
|
||||
// decipher.
|
||||
void CommandlineArgs::Args(winrt::array_view<const winrt::hstring> const& value)
|
||||
{
|
||||
_args = { value.begin(), value.end() };
|
||||
|
|
|
@ -95,16 +95,16 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
|
|||
bool Monarch::ProposeCommandline(array_view<const winrt::hstring> args,
|
||||
winrt::hstring cwd)
|
||||
{
|
||||
auto argsProcessed = 0;
|
||||
std::wstring fullCmdline;
|
||||
for (const auto& arg : args)
|
||||
{
|
||||
fullCmdline += argsProcessed++ == 0 ? L"sample.exe" : arg;
|
||||
fullCmdline += L" ";
|
||||
}
|
||||
wprintf(L"\x1b[36mProposed Commandline\x1b[m: \"");
|
||||
wprintf(fullCmdline.c_str());
|
||||
wprintf(L"\"\n");
|
||||
// auto argsProcessed = 0;
|
||||
// std::wstring fullCmdline;
|
||||
// for (const auto& arg : args)
|
||||
// {
|
||||
// fullCmdline += argsProcessed++ == 0 ? L"sample.exe" : arg;
|
||||
// fullCmdline += L" ";
|
||||
// }
|
||||
// wprintf(L"\x1b[36mProposed Commandline\x1b[m: \"");
|
||||
// wprintf(fullCmdline.c_str());
|
||||
// wprintf(L"\"\n");
|
||||
|
||||
bool createNewWindow = true;
|
||||
|
||||
|
@ -113,7 +113,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
|
|||
// We'll need three args at least - [WindowsTerminal.exe, -s,
|
||||
// id] to be able to have a session ID passed on the commandline.
|
||||
|
||||
if (args[1] == L"-s" || args[1] == L"--session")
|
||||
if (args[1] == L"-w" || args[1] == L"--window")
|
||||
{
|
||||
auto sessionId = std::stoi({ args[2].data(), args[2].size() });
|
||||
printf("Found a commandline intended for session %d\n", sessionId);
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
|
|||
private:
|
||||
uint64_t _id{ 0 };
|
||||
|
||||
winrt::Microsoft::Terminal::Remoting::CommandlineArgs _initialArgs; //{ nullptr };
|
||||
winrt::Microsoft::Terminal::Remoting::CommandlineArgs _initialArgs{ nullptr };
|
||||
|
||||
// array_view<const winrt::hstring> _args;
|
||||
// winrt::hstring _cwd;
|
||||
|
|
|
@ -28,7 +28,8 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
|
|||
_registrationHostClass = 0;
|
||||
}
|
||||
|
||||
void WindowManager::ProposeCommandline(array_view<const winrt::hstring> args, const winrt::hstring cwd)
|
||||
void WindowManager::ProposeCommandline(array_view<const winrt::hstring> args,
|
||||
const winrt::hstring cwd)
|
||||
{
|
||||
const bool isKing = _areWeTheKing();
|
||||
// If we're the king, we _definitely_ want to process the arguments, we were
|
||||
|
|
|
@ -142,21 +142,11 @@ void AppHost::SetTaskbarProgress(const winrt::Windows::Foundation::IInspectable&
|
|||
// - <none>
|
||||
void AppHost::_HandleCommandlineArgs()
|
||||
{
|
||||
if (auto commandline{ GetCommandLineW() })
|
||||
if (auto peasant{ _windowManager.CurrentWindow() })
|
||||
{
|
||||
int argc = 0;
|
||||
|
||||
// Get the argv, and turn them into a hstring array to pass to the app.
|
||||
wil::unique_any<LPWSTR*, decltype(&::LocalFree), ::LocalFree> argv{ CommandLineToArgvW(commandline, &argc) };
|
||||
if (argv)
|
||||
if (auto args{ peasant.InitialArgs() })
|
||||
{
|
||||
std::vector<winrt::hstring> args;
|
||||
for (auto& elem : wil::make_range(argv.get(), argc))
|
||||
{
|
||||
args.emplace_back(elem);
|
||||
}
|
||||
|
||||
const auto result = _logic.SetStartupCommandline({ args });
|
||||
const auto result = _logic.SetStartupCommandline(args.Args());
|
||||
const auto message = _logic.ParseCommandlineMessage();
|
||||
if (!message.empty())
|
||||
{
|
||||
|
@ -177,6 +167,41 @@ void AppHost::_HandleCommandlineArgs()
|
|||
}
|
||||
}
|
||||
}
|
||||
// if (auto commandline{ GetCommandLineW() })
|
||||
// {
|
||||
// int argc = 0;
|
||||
|
||||
// // Get the argv, and turn them into a hstring array to pass to the app.
|
||||
// wil::unique_any<LPWSTR*, decltype(&::LocalFree), ::LocalFree> argv{ CommandLineToArgvW(commandline, &argc) };
|
||||
// if (argv)
|
||||
// {
|
||||
// std::vector<winrt::hstring> args;
|
||||
// for (auto& elem : wil::make_range(argv.get(), argc))
|
||||
// {
|
||||
// args.emplace_back(elem);
|
||||
// }
|
||||
|
||||
// const auto result = _logic.SetStartupCommandline({ args });
|
||||
// const auto message = _logic.ParseCommandlineMessage();
|
||||
// if (!message.empty())
|
||||
// {
|
||||
// const auto displayHelp = result == 0;
|
||||
// const auto messageTitle = displayHelp ? IDS_HELP_DIALOG_TITLE : IDS_ERROR_DIALOG_TITLE;
|
||||
// const auto messageIcon = displayHelp ? MB_ICONWARNING : MB_ICONERROR;
|
||||
// // TODO:GH#4134: polish this dialog more, to make the text more
|
||||
// // like msiexec /?
|
||||
// MessageBoxW(nullptr,
|
||||
// message.data(),
|
||||
// GetStringResource(messageTitle).data(),
|
||||
// MB_OK | messageIcon);
|
||||
|
||||
// if (_logic.ShouldExitEarly())
|
||||
// {
|
||||
// ExitProcess(result);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
|
Loading…
Reference in a new issue