From 55f7ce118e3b515fb3b18425bb79e2dda1a2b97d Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Mon, 1 Jun 2020 16:39:33 -0500 Subject: [PATCH 1/3] This adds short-form aliases for each of the existing wt subcommands --- .../TerminalApp/AppCommandlineArgs.cpp | 201 ++++++++++-------- src/cascadia/TerminalApp/AppCommandlineArgs.h | 14 +- .../Resources/en-US/Resources.resw | 12 ++ 3 files changed, 137 insertions(+), 90 deletions(-) diff --git a/src/cascadia/TerminalApp/AppCommandlineArgs.cpp b/src/cascadia/TerminalApp/AppCommandlineArgs.cpp index 0d8dbec1a71..ae91a37d1e9 100644 --- a/src/cascadia/TerminalApp/AppCommandlineArgs.cpp +++ b/src/cascadia/TerminalApp/AppCommandlineArgs.cpp @@ -180,6 +180,7 @@ void AppCommandlineArgs::_buildParser() // Method Description: // - Adds the `new-tab` subcommand and related options to the commandline parser. +// - Additionally adds the `nt` subcommand, which is just a shortened version of `new-tab` // Arguments: // - // Return Value: @@ -187,27 +188,35 @@ void AppCommandlineArgs::_buildParser() void AppCommandlineArgs::_buildNewTabParser() { _newTabCommand.subcommand = _app.add_subcommand("new-tab", RS_A(L"CmdNewTabDesc")); - _addNewTerminalArgs(_newTabCommand); + _newTabShort.subcommand = _app.add_subcommand("nt", RS_A(L"CmdNTDesc")); + + auto setupSubcommand = [this](auto& subcommand) { + _addNewTerminalArgs(subcommand); + + // When ParseCommand is called, if this subcommand was provided, this + // callback function will be triggered on the same thread. We can be sure + // that `this` will still be safe - this function just lets us know this + // command was parsed. + subcommand.subcommand->callback([&, this]() { + // Build the NewTab action from the values we've parsed on the commandline. + auto newTabAction = winrt::make_self(); + newTabAction->Action(ShortcutAction::NewTab); + auto args = winrt::make_self(); + // _getNewTerminalArgs MUST be called before parsing any other options, + // as it might clear those options while finding the commandline + args->TerminalArgs(_getNewTerminalArgs(subcommand)); + newTabAction->Args(*args); + _startupActions.push_back(*newTabAction); + }); + }; - // When ParseCommand is called, if this subcommand was provided, this - // callback function will be triggered on the same thread. We can be sure - // that `this` will still be safe - this function just lets us know this - // command was parsed. - _newTabCommand.subcommand->callback([&, this]() { - // Build the NewTab action from the values we've parsed on the commandline. - auto newTabAction = winrt::make_self(); - newTabAction->Action(ShortcutAction::NewTab); - auto args = winrt::make_self(); - // _getNewTerminalArgs MUST be called before parsing any other options, - // as it might clear those options while finding the commandline - args->TerminalArgs(_getNewTerminalArgs(_newTabCommand)); - newTabAction->Args(*args); - _startupActions.push_back(*newTabAction); - }); + setupSubcommand(_newTabCommand); + setupSubcommand(_newTabShort); } // Method Description: // - Adds the `split-pane` subcommand and related options to the commandline parser. +// - Additionally adds the `sp` subcommand, which is just a shortened version of `split-pane` // Arguments: // - // Return Value: @@ -215,49 +224,57 @@ void AppCommandlineArgs::_buildNewTabParser() void AppCommandlineArgs::_buildSplitPaneParser() { _newPaneCommand.subcommand = _app.add_subcommand("split-pane", RS_A(L"CmdSplitPaneDesc")); - _addNewTerminalArgs(_newPaneCommand); - _horizontalOption = _newPaneCommand.subcommand->add_flag("-H,--horizontal", - _splitHorizontal, - RS_A(L"CmdSplitPaneHorizontalArgDesc")); - _verticalOption = _newPaneCommand.subcommand->add_flag("-V,--vertical", - _splitVertical, - RS_A(L"CmdSplitPaneVerticalArgDesc")); - _verticalOption->excludes(_horizontalOption); - - // When ParseCommand is called, if this subcommand was provided, this - // callback function will be triggered on the same thread. We can be sure - // that `this` will still be safe - this function just lets us know this - // command was parsed. - _newPaneCommand.subcommand->callback([&, this]() { - // Build the SplitPane action from the values we've parsed on the commandline. - auto splitPaneActionAndArgs = winrt::make_self(); - splitPaneActionAndArgs->Action(ShortcutAction::SplitPane); - auto args = winrt::make_self(); - // _getNewTerminalArgs MUST be called before parsing any other options, - // as it might clear those options while finding the commandline - args->TerminalArgs(_getNewTerminalArgs(_newPaneCommand)); - args->SplitStyle(SplitState::Automatic); - // Make sure to use the `Option`s here to check if they were set - - // _getNewTerminalArgs might reset them while parsing a commandline - if ((*_horizontalOption || *_verticalOption)) - { - if (_splitHorizontal) - { - args->SplitStyle(SplitState::Horizontal); - } - else if (_splitVertical) + _newPaneShort.subcommand = _app.add_subcommand("sp", RS_A(L"CmdSPDesc")); + + auto setupSubcommand = [this](auto& subcommand) { + _addNewTerminalArgs(subcommand); + subcommand._horizontalOption = subcommand.subcommand->add_flag("-H,--horizontal", + _splitHorizontal, + RS_A(L"CmdSplitPaneHorizontalArgDesc")); + subcommand._verticalOption = subcommand.subcommand->add_flag("-V,--vertical", + _splitVertical, + RS_A(L"CmdSplitPaneVerticalArgDesc")); + subcommand._verticalOption->excludes(subcommand._horizontalOption); + + // When ParseCommand is called, if this subcommand was provided, this + // callback function will be triggered on the same thread. We can be sure + // that `this` will still be safe - this function just lets us know this + // command was parsed. + subcommand.subcommand->callback([&, this]() { + // Build the SplitPane action from the values we've parsed on the commandline. + auto splitPaneActionAndArgs = winrt::make_self(); + splitPaneActionAndArgs->Action(ShortcutAction::SplitPane); + auto args = winrt::make_self(); + // _getNewTerminalArgs MUST be called before parsing any other options, + // as it might clear those options while finding the commandline + args->TerminalArgs(_getNewTerminalArgs(subcommand)); + args->SplitStyle(SplitState::Automatic); + // Make sure to use the `Option`s here to check if they were set - + // _getNewTerminalArgs might reset them while parsing a commandline + if ((*subcommand._horizontalOption || *subcommand._verticalOption)) { - args->SplitStyle(SplitState::Vertical); + if (_splitHorizontal) + { + args->SplitStyle(SplitState::Horizontal); + } + else if (_splitVertical) + { + args->SplitStyle(SplitState::Vertical); + } } - } - splitPaneActionAndArgs->Args(*args); - _startupActions.push_back(*splitPaneActionAndArgs); - }); + splitPaneActionAndArgs->Args(*args); + _startupActions.push_back(*splitPaneActionAndArgs); + }); + }; + + setupSubcommand(_newPaneCommand); + setupSubcommand(_newPaneShort); } // Method Description: -// - Adds the `new-tab` subcommand and related options to the commandline parser. +// - Adds the `focus-tab` subcommand and related options to the commandline parser. +// - Additionally adds the `ft` subcommand, which is just a shortened version of `focus-tab` // Arguments: // - // Return Value: @@ -265,39 +282,48 @@ void AppCommandlineArgs::_buildSplitPaneParser() void AppCommandlineArgs::_buildFocusTabParser() { _focusTabCommand = _app.add_subcommand("focus-tab", RS_A(L"CmdFocusTabDesc")); - auto* indexOpt = _focusTabCommand->add_option("-t,--target", _focusTabIndex, RS_A(L"CmdFocusTabTargetArgDesc")); - auto* nextOpt = _focusTabCommand->add_flag("-n,--next", - _focusNextTab, - RS_A(L"CmdFocusTabNextArgDesc")); - auto* prevOpt = _focusTabCommand->add_flag("-p,--previous", - _focusPrevTab, - RS_A(L"CmdFocusTabPrevArgDesc")); - nextOpt->excludes(prevOpt); - indexOpt->excludes(prevOpt); - indexOpt->excludes(nextOpt); - - // When ParseCommand is called, if this subcommand was provided, this - // callback function will be triggered on the same thread. We can be sure - // that `this` will still be safe - this function just lets us know this - // command was parsed. - _focusTabCommand->callback([&, this]() { - // Build the action from the values we've parsed on the commandline. - auto focusTabAction = winrt::make_self(); - - if (_focusTabIndex >= 0) - { - focusTabAction->Action(ShortcutAction::SwitchToTab); - auto args = winrt::make_self(); - args->TabIndex(_focusTabIndex); - focusTabAction->Args(*args); - _startupActions.push_back(*focusTabAction); - } - else if (_focusNextTab || _focusPrevTab) - { - focusTabAction->Action(_focusNextTab ? ShortcutAction::NextTab : ShortcutAction::PrevTab); - _startupActions.push_back(*focusTabAction); - } - }); + _focusTabShort = _app.add_subcommand("ft", RS_A(L"CmdFTDesc")); + + auto setupSubcommand = [this](auto* subcommand) { + auto* indexOpt = subcommand->add_option("-t,--target", + _focusTabIndex, + RS_A(L"CmdFocusTabTargetArgDesc")); + auto* nextOpt = subcommand->add_flag("-n,--next", + _focusNextTab, + RS_A(L"CmdFocusTabNextArgDesc")); + auto* prevOpt = subcommand->add_flag("-p,--previous", + _focusPrevTab, + RS_A(L"CmdFocusTabPrevArgDesc")); + nextOpt->excludes(prevOpt); + indexOpt->excludes(prevOpt); + indexOpt->excludes(nextOpt); + + // When ParseCommand is called, if this subcommand was provided, this + // callback function will be triggered on the same thread. We can be sure + // that `this` will still be safe - this function just lets us know this + // command was parsed. + subcommand->callback([&, this]() { + // Build the action from the values we've parsed on the commandline. + auto focusTabAction = winrt::make_self(); + + if (_focusTabIndex >= 0) + { + focusTabAction->Action(ShortcutAction::SwitchToTab); + auto args = winrt::make_self(); + args->TabIndex(_focusTabIndex); + focusTabAction->Args(*args); + _startupActions.push_back(*focusTabAction); + } + else if (_focusNextTab || _focusPrevTab) + { + focusTabAction->Action(_focusNextTab ? ShortcutAction::NextTab : ShortcutAction::PrevTab); + _startupActions.push_back(*focusTabAction); + } + }); + }; + + setupSubcommand(_focusTabCommand); + setupSubcommand(_focusTabShort); } // Method Description: @@ -386,7 +412,10 @@ NewTerminalArgs AppCommandlineArgs::_getNewTerminalArgs(AppCommandlineArgs::NewT bool AppCommandlineArgs::_noCommandsProvided() { return !(*_newTabCommand.subcommand || + *_newTabShort.subcommand || *_focusTabCommand || + *_focusTabShort || + *_newPaneShort.subcommand || *_newPaneCommand.subcommand); } diff --git a/src/cascadia/TerminalApp/AppCommandlineArgs.h b/src/cascadia/TerminalApp/AppCommandlineArgs.h index 1a46d644b8a..d5b805c1349 100644 --- a/src/cascadia/TerminalApp/AppCommandlineArgs.h +++ b/src/cascadia/TerminalApp/AppCommandlineArgs.h @@ -53,15 +53,21 @@ class TerminalApp::AppCommandlineArgs final CLI::Option* startingDirectoryOption; }; + struct NewPaneSubcommand : public NewTerminalSubcommand + { + CLI::Option* _horizontalOption; + CLI::Option* _verticalOption; + }; + // --- Subcommands --- NewTerminalSubcommand _newTabCommand; - NewTerminalSubcommand _newPaneCommand; + NewTerminalSubcommand _newTabShort; + NewPaneSubcommand _newPaneCommand; + NewPaneSubcommand _newPaneShort; CLI::App* _focusTabCommand; + CLI::App* _focusTabShort; // Are you adding a new sub-command? Make sure to update _noCommandsProvided! - CLI::Option* _horizontalOption; - CLI::Option* _verticalOption; - std::string _profileName; std::string _startingDirectory; diff --git a/src/cascadia/TerminalApp/Resources/en-US/Resources.resw b/src/cascadia/TerminalApp/Resources/en-US/Resources.resw index bdc3cf861e8..6a63d079b45 100644 --- a/src/cascadia/TerminalApp/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalApp/Resources/en-US/Resources.resw @@ -231,6 +231,10 @@ Move focus to the next tab + + An alias for the "focus-tab" subcommand. + {Locked="\"focus-tab\""} + Move focus to the previous tab @@ -240,12 +244,20 @@ Create a new tab + + An alias for the "new-tab" subcommand. + {Locked="\"new-tab\""} + Open with the given profile. Accepts either the name or GUID of a profile Create a new split pane + + An alias for the "split-pane" subcommand. + {Locked="\"split-pane\""} + Create the new pane as a horizontal split (think [-]) From 4cf5376356cc2d04ea83c406a108a8791abe3758 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Mon, 1 Jun 2020 16:56:22 -0500 Subject: [PATCH 2/3] Get the tests to pass as well --- .../CommandlineTest.cpp | 73 +++++++++++++------ 1 file changed, 52 insertions(+), 21 deletions(-) diff --git a/src/cascadia/LocalTests_TerminalApp/CommandlineTest.cpp b/src/cascadia/LocalTests_TerminalApp/CommandlineTest.cpp index e6e67bdb373..57f45319b16 100644 --- a/src/cascadia/LocalTests_TerminalApp/CommandlineTest.cpp +++ b/src/cascadia/LocalTests_TerminalApp/CommandlineTest.cpp @@ -388,9 +388,16 @@ namespace TerminalAppLocalTests void CommandlineTest::ParseNewTabCommand() { + BEGIN_TEST_METHOD_PROPERTIES() + TEST_METHOD_PROPERTY(L"Data:useShortForm", L"{false, true}") + END_TEST_METHOD_PROPERTIES() + + INIT_TEST_PROPERTY(bool, useShortForm, L"TODO"); + const wchar_t* subcommand = useShortForm ? L"nt" : L"new-tab"; + { AppCommandlineArgs appArgs{}; - std::vector rawCommands{ L"wt.exe", L"new-tab" }; + std::vector rawCommands{ L"wt.exe", subcommand }; _buildCommandlinesHelper(appArgs, 1u, rawCommands); VERIFY_ARE_EQUAL(1u, appArgs._startupActions.size()); @@ -409,7 +416,7 @@ namespace TerminalAppLocalTests } { AppCommandlineArgs appArgs{}; - std::vector rawCommands{ L"wt.exe", L"new-tab", L"--profile", L"cmd" }; + std::vector rawCommands{ L"wt.exe", subcommand, L"--profile", L"cmd" }; _buildCommandlinesHelper(appArgs, 1u, rawCommands); VERIFY_ARE_EQUAL(1u, appArgs._startupActions.size()); @@ -429,7 +436,7 @@ namespace TerminalAppLocalTests } { AppCommandlineArgs appArgs{}; - std::vector rawCommands{ L"wt.exe", L"new-tab", L"--startingDirectory", L"c:\\Foo" }; + std::vector rawCommands{ L"wt.exe", subcommand, L"--startingDirectory", L"c:\\Foo" }; _buildCommandlinesHelper(appArgs, 1u, rawCommands); VERIFY_ARE_EQUAL(1u, appArgs._startupActions.size()); @@ -449,7 +456,7 @@ namespace TerminalAppLocalTests } { AppCommandlineArgs appArgs{}; - std::vector rawCommands{ L"wt.exe", L"new-tab", L"powershell.exe" }; + std::vector rawCommands{ L"wt.exe", subcommand, L"powershell.exe" }; _buildCommandlinesHelper(appArgs, 1u, rawCommands); VERIFY_ARE_EQUAL(1u, appArgs._startupActions.size()); @@ -469,7 +476,7 @@ namespace TerminalAppLocalTests } { AppCommandlineArgs appArgs{}; - std::vector rawCommands{ L"wt.exe", L"new-tab", L"powershell.exe", L"This is an arg with spaces" }; + std::vector rawCommands{ L"wt.exe", subcommand, L"powershell.exe", L"This is an arg with spaces" }; _buildCommandlinesHelper(appArgs, 1u, rawCommands); VERIFY_ARE_EQUAL(1u, appArgs._startupActions.size()); @@ -490,7 +497,7 @@ namespace TerminalAppLocalTests } { AppCommandlineArgs appArgs{}; - std::vector rawCommands{ L"wt.exe", L"new-tab", L"powershell.exe", L"This is an arg with spaces", L"another-arg", L"more spaces in this one" }; + std::vector rawCommands{ L"wt.exe", subcommand, L"powershell.exe", L"This is an arg with spaces", L"another-arg", L"more spaces in this one" }; _buildCommandlinesHelper(appArgs, 1u, rawCommands); VERIFY_ARE_EQUAL(1u, appArgs._startupActions.size()); @@ -511,7 +518,7 @@ namespace TerminalAppLocalTests } { AppCommandlineArgs appArgs{}; - std::vector rawCommands{ L"wt.exe", L"new-tab", L"-p", L"Windows PowerShell" }; + std::vector rawCommands{ L"wt.exe", subcommand, L"-p", L"Windows PowerShell" }; _buildCommandlinesHelper(appArgs, 1u, rawCommands); VERIFY_ARE_EQUAL(1u, appArgs._startupActions.size()); @@ -531,7 +538,7 @@ namespace TerminalAppLocalTests } { AppCommandlineArgs appArgs{}; - std::vector rawCommands{ L"wt.exe", L"new-tab", L"wsl", L"-d", L"Alpine" }; + std::vector rawCommands{ L"wt.exe", subcommand, L"wsl", L"-d", L"Alpine" }; _buildCommandlinesHelper(appArgs, 1u, rawCommands); VERIFY_ARE_EQUAL(1u, appArgs._startupActions.size()); @@ -551,7 +558,7 @@ namespace TerminalAppLocalTests } { AppCommandlineArgs appArgs{}; - std::vector rawCommands{ L"wt.exe", L"new-tab", L"-p", L"1", L"wsl", L"-d", L"Alpine" }; + std::vector rawCommands{ L"wt.exe", subcommand, L"-p", L"1", L"wsl", L"-d", L"Alpine" }; _buildCommandlinesHelper(appArgs, 1u, rawCommands); VERIFY_ARE_EQUAL(1u, appArgs._startupActions.size()); @@ -574,9 +581,16 @@ namespace TerminalAppLocalTests void CommandlineTest::ParseSplitPaneIntoArgs() { + BEGIN_TEST_METHOD_PROPERTIES() + TEST_METHOD_PROPERTY(L"Data:useShortForm", L"{false, true}") + END_TEST_METHOD_PROPERTIES() + + INIT_TEST_PROPERTY(bool, useShortForm, L"TODO"); + const wchar_t* subcommand = useShortForm ? L"sp" : L"split-pane"; + { AppCommandlineArgs appArgs{}; - std::vector rawCommands{ L"wt.exe", L"split-pane" }; + std::vector rawCommands{ L"wt.exe", subcommand }; _buildCommandlinesHelper(appArgs, 1u, rawCommands); VERIFY_ARE_EQUAL(2u, appArgs._startupActions.size()); @@ -595,7 +609,7 @@ namespace TerminalAppLocalTests } { AppCommandlineArgs appArgs{}; - std::vector rawCommands{ L"wt.exe", L"split-pane", L"-H" }; + std::vector rawCommands{ L"wt.exe", subcommand, L"-H" }; _buildCommandlinesHelper(appArgs, 1u, rawCommands); VERIFY_ARE_EQUAL(2u, appArgs._startupActions.size()); @@ -614,7 +628,7 @@ namespace TerminalAppLocalTests } { AppCommandlineArgs appArgs{}; - std::vector rawCommands{ L"wt.exe", L"split-pane", L"-V" }; + std::vector rawCommands{ L"wt.exe", subcommand, L"-V" }; auto commandlines = AppCommandlineArgs::BuildCommands(rawCommands); VERIFY_ARE_EQUAL(1u, commandlines.size()); _buildCommandlinesHelper(appArgs, 1u, rawCommands); @@ -635,7 +649,7 @@ namespace TerminalAppLocalTests } { AppCommandlineArgs appArgs{}; - std::vector rawCommands{ L"wt.exe", L"split-pane", L"-p", L"1", L"wsl", L"-d", L"Alpine" }; + std::vector rawCommands{ L"wt.exe", subcommand, L"-p", L"1", L"wsl", L"-d", L"Alpine" }; auto commandlines = AppCommandlineArgs::BuildCommands(rawCommands); VERIFY_ARE_EQUAL(1u, commandlines.size()); _buildCommandlinesHelper(appArgs, 1u, rawCommands); @@ -662,7 +676,7 @@ namespace TerminalAppLocalTests } { AppCommandlineArgs appArgs{}; - std::vector rawCommands{ L"wt.exe", L"split-pane", L"-p", L"1", L"-H", L"wsl", L"-d", L"Alpine" }; + std::vector rawCommands{ L"wt.exe", subcommand, L"-p", L"1", L"-H", L"wsl", L"-d", L"Alpine" }; auto commandlines = AppCommandlineArgs::BuildCommands(rawCommands); VERIFY_ARE_EQUAL(1u, commandlines.size()); _buildCommandlinesHelper(appArgs, 1u, rawCommands); @@ -689,7 +703,7 @@ namespace TerminalAppLocalTests } { AppCommandlineArgs appArgs{}; - std::vector rawCommands{ L"wt.exe", L"split-pane", L"-p", L"1", L"wsl", L"-d", L"Alpine", L"-H" }; + std::vector rawCommands{ L"wt.exe", subcommand, L"-p", L"1", L"wsl", L"-d", L"Alpine", L"-H" }; auto commandlines = AppCommandlineArgs::BuildCommands(rawCommands); VERIFY_ARE_EQUAL(1u, commandlines.size()); _buildCommandlinesHelper(appArgs, 1u, rawCommands); @@ -718,8 +732,18 @@ namespace TerminalAppLocalTests void CommandlineTest::ParseComboCommandlineIntoArgs() { + BEGIN_TEST_METHOD_PROPERTIES() + TEST_METHOD_PROPERTY(L"Data:useShortFormNewTab", L"{false, true}") + TEST_METHOD_PROPERTY(L"Data:useShortFormSplitPane", L"{false, true}") + END_TEST_METHOD_PROPERTIES() + + INIT_TEST_PROPERTY(bool, useShortFormNewTab, L"TODO"); + INIT_TEST_PROPERTY(bool, useShortFormSplitPane, L"TODO"); + const wchar_t* ntSubcommand = useShortFormNewTab ? L"nt" : L"new-tab"; + const wchar_t* spSubcommand = useShortFormSplitPane ? L"sp" : L"split-pane"; + AppCommandlineArgs appArgs{}; - std::vector rawCommands{ L"wt.exe", L"new-tab", L";", L"split-pane" }; + std::vector rawCommands{ L"wt.exe", ntSubcommand, L";", spSubcommand }; auto commandlines = AppCommandlineArgs::BuildCommands(rawCommands); _buildCommandlinesHelper(appArgs, 2u, rawCommands); @@ -834,9 +858,16 @@ namespace TerminalAppLocalTests void CommandlineTest::ParseFocusTabArgs() { + BEGIN_TEST_METHOD_PROPERTIES() + TEST_METHOD_PROPERTY(L"Data:useShortForm", L"{false, true}") + END_TEST_METHOD_PROPERTIES() + + INIT_TEST_PROPERTY(bool, useShortForm, L"TODO"); + const wchar_t* subcommand = useShortForm ? L"ft" : L"focus-tab"; + { AppCommandlineArgs appArgs{}; - std::vector rawCommands{ L"wt.exe", L"focus-tab" }; + std::vector rawCommands{ L"wt.exe", subcommand }; _buildCommandlinesHelper(appArgs, 1u, rawCommands); VERIFY_ARE_EQUAL(1u, appArgs._startupActions.size()); @@ -846,7 +877,7 @@ namespace TerminalAppLocalTests } { AppCommandlineArgs appArgs{}; - std::vector rawCommands{ L"wt.exe", L"focus-tab", L"-n" }; + std::vector rawCommands{ L"wt.exe", subcommand, L"-n" }; _buildCommandlinesHelper(appArgs, 1u, rawCommands); VERIFY_ARE_EQUAL(2u, appArgs._startupActions.size()); @@ -860,7 +891,7 @@ namespace TerminalAppLocalTests } { AppCommandlineArgs appArgs{}; - std::vector rawCommands{ L"wt.exe", L"focus-tab", L"-p" }; + std::vector rawCommands{ L"wt.exe", subcommand, L"-p" }; _buildCommandlinesHelper(appArgs, 1u, rawCommands); VERIFY_ARE_EQUAL(2u, appArgs._startupActions.size()); @@ -874,7 +905,7 @@ namespace TerminalAppLocalTests } { AppCommandlineArgs appArgs{}; - std::vector rawCommands{ L"wt.exe", L"focus-tab", L"-t", L"2" }; + std::vector rawCommands{ L"wt.exe", subcommand, L"-t", L"2" }; _buildCommandlinesHelper(appArgs, 1u, rawCommands); VERIFY_ARE_EQUAL(2u, appArgs._startupActions.size()); @@ -894,7 +925,7 @@ namespace TerminalAppLocalTests Log::Comment(NoThrowString().Format( L"Attempt an invalid combination of flags")); AppCommandlineArgs appArgs{}; - std::vector rawCommands{ L"wt.exe", L"focus-tab", L"-p", L"-n" }; + std::vector rawCommands{ L"wt.exe", subcommand, L"-p", L"-n" }; auto commandlines = AppCommandlineArgs::BuildCommands(rawCommands); VERIFY_ARE_EQUAL(1u, commandlines.size()); From 3c6bd72e22c9b34282ca69d2654c08a733b58f8c Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 18 Jun 2020 14:29:03 -0500 Subject: [PATCH 3/3] clean up leftover todos --- .../LocalTests_TerminalApp/CommandlineTest.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cascadia/LocalTests_TerminalApp/CommandlineTest.cpp b/src/cascadia/LocalTests_TerminalApp/CommandlineTest.cpp index 57f45319b16..e9191a4f2f5 100644 --- a/src/cascadia/LocalTests_TerminalApp/CommandlineTest.cpp +++ b/src/cascadia/LocalTests_TerminalApp/CommandlineTest.cpp @@ -392,7 +392,7 @@ namespace TerminalAppLocalTests TEST_METHOD_PROPERTY(L"Data:useShortForm", L"{false, true}") END_TEST_METHOD_PROPERTIES() - INIT_TEST_PROPERTY(bool, useShortForm, L"TODO"); + INIT_TEST_PROPERTY(bool, useShortForm, L"If true, use `nt` instead of `new-tab`"); const wchar_t* subcommand = useShortForm ? L"nt" : L"new-tab"; { @@ -585,7 +585,7 @@ namespace TerminalAppLocalTests TEST_METHOD_PROPERTY(L"Data:useShortForm", L"{false, true}") END_TEST_METHOD_PROPERTIES() - INIT_TEST_PROPERTY(bool, useShortForm, L"TODO"); + INIT_TEST_PROPERTY(bool, useShortForm, L"If true, use `sp` instead of `split-pane`"); const wchar_t* subcommand = useShortForm ? L"sp" : L"split-pane"; { @@ -737,8 +737,8 @@ namespace TerminalAppLocalTests TEST_METHOD_PROPERTY(L"Data:useShortFormSplitPane", L"{false, true}") END_TEST_METHOD_PROPERTIES() - INIT_TEST_PROPERTY(bool, useShortFormNewTab, L"TODO"); - INIT_TEST_PROPERTY(bool, useShortFormSplitPane, L"TODO"); + INIT_TEST_PROPERTY(bool, useShortFormNewTab, L"If true, use `nt` instead of `new-tab`"); + INIT_TEST_PROPERTY(bool, useShortFormSplitPane, L"If true, use `sp` instead of `split-pane`"); const wchar_t* ntSubcommand = useShortFormNewTab ? L"nt" : L"new-tab"; const wchar_t* spSubcommand = useShortFormSplitPane ? L"sp" : L"split-pane"; @@ -862,7 +862,7 @@ namespace TerminalAppLocalTests TEST_METHOD_PROPERTY(L"Data:useShortForm", L"{false, true}") END_TEST_METHOD_PROPERTIES() - INIT_TEST_PROPERTY(bool, useShortForm, L"TODO"); + INIT_TEST_PROPERTY(bool, useShortForm, L"If true, use `ft` instead of `focus-tab`"); const wchar_t* subcommand = useShortForm ? L"ft" : L"focus-tab"; {