From 88db0e61025df7b10c59ca5e8ee0905b15195cab Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Tue, 2 Jun 2020 13:52:08 -0500 Subject: [PATCH] Add support for `--title` to the `wt.exe` commandline args (#6296) ## Summary of the Pull Request Adds support for setting the terminal `title` with the commandline argument `--title `. ## PR Checklist * [x] Closes #6183 * [x] I work here * [ ] Tests added/passed * [ ] Requires documentation to be updated - probably does, yea ## Detailed Description of the Pull Request / Additional comments * I wasn't sure how we felt about `-t` being the short version of this argument, so I left it out. If we're cool with that, adding it wouldn't be hard. ## Validation Steps Performed ![image](https://user-images.githubusercontent.com/18356694/83450866-afe03480-a41b-11ea-84e7-9134474fdd7a.png) --- src/cascadia/TerminalApp/AppCommandlineArgs.cpp | 9 +++++++++ src/cascadia/TerminalApp/AppCommandlineArgs.h | 2 ++ src/cascadia/TerminalApp/Resources/en-US/Resources.resw | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/src/cascadia/TerminalApp/AppCommandlineArgs.cpp b/src/cascadia/TerminalApp/AppCommandlineArgs.cpp index 62116961957..769be092157 100644 --- a/src/cascadia/TerminalApp/AppCommandlineArgs.cpp +++ b/src/cascadia/TerminalApp/AppCommandlineArgs.cpp @@ -330,6 +330,9 @@ void AppCommandlineArgs::_addNewTerminalArgs(AppCommandlineArgs::NewTerminalSubc subcommand.startingDirectoryOption = subcommand.subcommand->add_option("-d,--startingDirectory", _startingDirectory, RS_A(L"CmdStartingDirArgDesc")); + subcommand.titleOption = subcommand.subcommand->add_option("--title", + _startingTitle, + RS_A(L"CmdTitleArgDesc")); // Using positionals_at_end allows us to support "wt new-tab -d wsl -d Ubuntu" // without CLI11 thinking that we've specified -d twice. @@ -387,6 +390,11 @@ NewTerminalArgs AppCommandlineArgs::_getNewTerminalArgs(AppCommandlineArgs::NewT args->StartingDirectory(winrt::to_hstring(_startingDirectory)); } + if (*subcommand.titleOption) + { + args->TabTitle(winrt::to_hstring(_startingTitle)); + } + return *args; } @@ -417,6 +425,7 @@ void AppCommandlineArgs::_resetStateToDefault() { _profileName.clear(); _startingDirectory.clear(); + _startingTitle.clear(); _commandline.clear(); _splitVertical = false; diff --git a/src/cascadia/TerminalApp/AppCommandlineArgs.h b/src/cascadia/TerminalApp/AppCommandlineArgs.h index 268ce55a037..37bcf51fa98 100644 --- a/src/cascadia/TerminalApp/AppCommandlineArgs.h +++ b/src/cascadia/TerminalApp/AppCommandlineArgs.h @@ -53,6 +53,7 @@ class TerminalApp::AppCommandlineArgs final CLI::Option* commandlineOption; CLI::Option* profileNameOption; CLI::Option* startingDirectoryOption; + CLI::Option* titleOption; }; // --- Subcommands --- @@ -66,6 +67,7 @@ class TerminalApp::AppCommandlineArgs final std::string _profileName; std::string _startingDirectory; + std::string _startingTitle; // _commandline will contain the command line with which we'll be spawning a new terminal std::vector<std::string> _commandline; diff --git a/src/cascadia/TerminalApp/Resources/en-US/Resources.resw b/src/cascadia/TerminalApp/Resources/en-US/Resources.resw index 6afdb0e006c..b6fee2b14b1 100644 --- a/src/cascadia/TerminalApp/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalApp/Resources/en-US/Resources.resw @@ -256,6 +256,10 @@ <value>Open in the given directory instead of the profile's set "startingDirectory"</value> <comment>{Locked="\"startingDirectory\""}</comment> </data> + <data name="CmdTitleArgDesc" xml:space="preserve"> + <value>Open the terminal with the provided title instead of the profile's set "title"</value> + <comment>{Locked="\"title\""}</comment> + </data> <data name="CmdVersionDesc" xml:space="preserve"> <value>Display the application version</value> </data>