terminal/src/cascadia/TerminalApp/Commandline.h
Mike Griese 830c22b73e Add support for commandline args to wt.exe (#4023)
## Summary of the Pull Request

Adds support for commandline arguments to the Windows Terminal, in accordance with the spec in #3495

## References

* Original issue: #607
* Original spec: #3495

## PR Checklist
* [x] Closes #607
* [x] I work here
* [x] Tests added/passed
* [ ] We should probably add some docs on these commands
* [x] The spec (#3495) needs to be merged first!

## Detailed Description of the Pull Request / Additional comments

🛑 **STOP** 🛑 - have you read #3495 yet? If you haven't, go do that now.

This PR adds support for three initial sub-commands to the `wt.exe` application:
* `new-tab`: Used to create a new tab.
* `split-pane`: Used to create a new split.
* `focus-tab`: Moves focus to another tab.

These commands are largely POC to prove that the commandlines work. They're not totally finished, but they work well enough. Follow up work items will be filed to track adding support for additional parameters and subcommands

Important scenarios added:
* `wt -d .`: Open a new wt instance in the current working directory #878
* `wt -p <profile name>`: Create a wt instance running the given profile, to unblock  #576, #1357, #2339
* `wt ; new-tab ; split-pane -V`: Launch the terminal with multiple tabs, splits, to unblock #756 

## Validation Steps Performed

* Ran tests
* Played with it a bunch
2020-01-27 15:34:12 +00:00

47 lines
1.3 KiB
C++

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//
// Module Name:
// - Commandline.h
//
// Abstract:
// - This is a helper class for representing a single commandline within the
// Terminal Application. Users can specify multiple commands on a single
// commandline invocation of the Terminal, and this class is used to represent
// a single individual command.
// - Args are added to this class as wide strings, because the args provided to
// the application are typically wide strings.
// - Args are retrieved from this class as a list of narrow-strings, because
// CLI11 (which we're using to parse the commandlines) requires narrow
// strings.
//
// Author:
// - Mike Griese (zadjii-msft) 09-Jan-2020
// fwdecl unittest classes
namespace TerminalAppLocalTests
{
class CommandlineTest;
};
namespace TerminalApp
{
class Commandline;
};
class TerminalApp::Commandline
{
public:
static constexpr std::wstring_view Delimiter{ L";" };
static constexpr std::wstring_view EscapedDelimiter{ L"\\;" };
void AddArg(const std::wstring& nextArg);
size_t Argc() const;
const std::vector<std::string>& Args() const;
private:
std::vector<std::string> _args;
friend class TerminalAppLocalTests::CommandlineTest;
};