Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for commandline args to wt.exe #4023

Merged
53 commits merged into from
Jan 27, 2020
Merged

Conversation

zadjii-msft
Copy link
Member

@zadjii-msft zadjii-msft commented Dec 19, 2019

Summary of the Pull Request

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

References

PR Checklist

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:

Validation Steps Performed

  • Ran tests
  • Played with it a bunch

…tbase!

  When we startup, we currently have a `Title`, because we always have a Tab.

  With commandline args, we'll sometimes _not_ have a tab immediately. In that case, this would crash
Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally got through all of it. Here's a few comments. This thing is awesome!

Don't feel comfortable approving it until I actually download the branch and play with it a bit. I can do that once Seattle Snowpocalypse 2020 ends and I get back into the office (assuming it isn't merged by then).

src/cascadia/WindowsTerminal/AppHost.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/TerminalPage.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/TerminalPage.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/AppCommandlineArgs.h Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/AppCommandlineArgs.cpp Outdated Show resolved Hide resolved
@carlos-zamora
Copy link
Member

Don't feel comfortable approving it until I actually download the branch and play with it a bit. I can do that once Seattle Snowpocalypse 2020 ends and I get back into the office (assuming it isn't merged by then).

Alright, got a chance to play with it. Found a few issues:

  • I build/deploy your branch. In this terminal ("termA"), I execute command "wtd" in powershell. I get a new terminal instance with the default profile properly. TermA no longer accepts input. I then close the new terminal instance, and this happens...
 	Microsoft.Toolkit.Win32.UI.XamlHost.dll!00007ffd9fcc3e99()	Unknown
>	Windows.UI.Xaml.dll!ctl::release_interface<DirectUI::SettingsFlyoutMetadata>(DirectUI::SettingsFlyoutMetadata * & pInterface) Line 137	C++
 	[Inline Frame] Windows.UI.Xaml.dll!DirectUI::FrameworkApplication::GlobalDeinit() Line 668	C++
 	Windows.UI.Xaml.dll!DeinitializeDll() Line 319	C++
 	Windows.UI.Xaml.dll!DllMain(HINSTANCE__ * hinstDLL, unsigned int fdwReason, void * __formal) Line 394	C++
 	Windows.UI.Xaml.dll!dllmain_dispatch(HINSTANCE__ * const instance, const unsigned long reason, void * const reserved) Line 200	C++
 	ntdll.dll!LdrpCallInitRoutine(unsigned char(*)(void *, unsigned long, _CONTEXT *) InitRoutine, void * DllHandle, unsigned long Reason, _CONTEXT * Context) Line 212	C

When executed from CMD, TermA still accepts input. But upon closing the new terminal instance, the same exception is thrown.

  • "wtd.exe" does nothing when in wsl (using Ubuntu distro, if it matters)

Is there any way to fix this? ☹

@zadjii-msft
Copy link
Member Author

@carlos-zamora:
That crash is a XAML crash that I was supposed to file on the MUX repo. It only happens in debug, and it's been happening for a while now actually 😄

TermA no longer accepts input
wat? Maybe this is just a powershell thing, and it should be wtd &? @DHowett-MSFT thoughts here?

Also, I'm not sure any execution aliases work in wsl. ubuntu.exe doesn't work for me. Not sure there's anything we can do about that.

@DHowett-MSFT
Copy link
Contributor

DHowett-MSFT commented Jan 16, 2020

Yes, that’s because powershell 6 cannot detect app execution aliases for their subsystem.

@carlos-zamora
Copy link
Member

@carlos-zamora:
That crash is a XAML crash that I was supposed to file on the MUX repo. It only happens in debug, and it's been happening for a while now actually 😄

Derp. That's what I get for being in accessibility-land for so long haha.

TermA no longer accepts input
wat? Maybe this is just a powershell thing, and it should be wtd &? @DHowett-MSFT thoughts here?

Also, I'm not sure any execution aliases work in wsl. ubuntu.exe doesn't work for me. Not sure there's anything we can do about that.

But I thought one of the cool things with WSL was that you can just run things like "notepad.exe" or any windows executable and it just works.

@DHowett-MSFT
Copy link
Contributor

DHowett-MSFT commented Jan 24, 2020

notepad.exe isn’t an app execution alias. That issue (inbox) pertains only to the little alias files that the app platform emits for applications inside an appx.

Copy link
Contributor

@DHowett-MSFT DHowett-MSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nits, but not enough to blockk

src/cascadia/TerminalApp/AppCommandlineArgs.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/AppCommandlineArgs.cpp Outdated Show resolved Hide resolved
Comment on lines +368 to +378
if (arg.find(" ") != std::string::npos)
{
fullCommandlineBuffer += "\"";
fullCommandlineBuffer += arg;
fullCommandlineBuffer += "\"";
}
else
{
fullCommandlineBuffer += arg;
}
fullCommandlineBuffer += " ";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

big dislike. please file a bug on CLI11 to request a mode that lets us get everything after the first non-parameter string verbatim in the right format.

// that produces a NewTerminalArgs.
struct NewTerminalSubcommand
{
CLI::App* subcommand;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't 100% understand how a subcommand has-a subcommand, but I am willing to accept it

CLI::App* _focusTabCommand;
// Are you adding a new sub-command? Make sure to update _noCommandsProvided!

CLI::Option* _horizontalOption;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these seem unusually global

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(to all Args)

@zadjii-msft zadjii-msft added the AutoMerge Marked for automatic merge by the bot when requirements are met label Jan 27, 2020
@ghost
Copy link

ghost commented Jan 27, 2020

Hello @zadjii-msft!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 830c22b into master Jan 27, 2020
@ghost ghost deleted the dev/migrie/f/607-handle-args branch January 27, 2020 15:34
@ghost
Copy link

ghost commented Feb 13, 2020

🎉Windows Terminal Preview v0.9.433.0 has been released which incorporates this pull request.:tada:

Handy links:

@UrbanPotato
Copy link

UrbanPotato commented Mar 18, 2020

this works around #756 with the following syntax less then ideal but it gets it done
wt -p "Windows Powershell" ; cmd ; ubuntu

shame there is not a good way to simply just tic a box and have this be the default

I should not need to use batch files to launch the terminal thats the entire point of having a new terminal lol

we are circling around this issue really getting support for simply having some default options that don't require digging around in a json file would close three issue and probly more I don't know about

#756
#4601
#4632

I don't think this should wait for post 1.0 this is sorta a killer feature most Linux terminals support being configured as such and it would help push people to use windows terminal which is the end game here

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal AutoMerge Marked for automatic merge by the bot when requirements are met Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: wt.exe supports command line arguments (profile, command, directory, etc.)
6 participants