X Tutup
The Wayback Machine - https://web.archive.org/web/20201202080647/https://github.com/PowerShell/PSReadLine/issues/1818
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

Make completer menus reusable #1818

Open
Jaykul opened this issue Sep 17, 2020 · 6 comments
Open

Make completer menus reusable #1818

Jaykul opened this issue Sep 17, 2020 · 6 comments

Comments

@Jaykul
Copy link

@Jaykul Jaykul commented Sep 17, 2020

Regarding the existing MenuComplete function (Ctrl+Space) and the new "F2" history menu, a couple of requests:

  1. Can we expose these menus as commands to make them usable by other modules as a way to prompt for input? It's always frustrating for PowerShell script authors that $Host.UI.PromptForChoice is so hard to use ...
  2. Can we offer an command to turn one of these menus "on by default" to provide a slightly more intellisense-like feel to the prompt? Most people won't want that all the time, but it could be super useful on a temporary basis (particularly for learning new modules, since the MenuComplete completer shows the full syntax block for commands):
    image
@daxian-dbw
Copy link
Member

@daxian-dbw daxian-dbw commented Oct 5, 2020

For your comment (1), MenuComplete is part of PSReadLine, not the host. That means it won't be generally available to all applications that hosts PowerShell and thus won't be reliable for a module to use. Are you suggesting to move MenuComplete to PowerShell host?

@vexx32
Copy link

@vexx32 vexx32 commented Oct 5, 2020

More sounds like the ask is to provide a PSReadLine cmdlet that allows users to invoke a MenuComplete (for F2) action for more general purposes, rather than just being a PSReadLine builtin functionality that is otherwise entirely inaccessible.

@daxian-dbw
Copy link
Member

@daxian-dbw daxian-dbw commented Oct 5, 2020

Right, but that depends on the PSReadLine module to be available, which may not be the case for a custom PowerShell host. So a module cannot use that to replace the $Host.UI.PromptForChoice call because the latter is part of the base type of the host, which is generally available.

@Jaykul
Copy link
Author

@Jaykul Jaykul commented Oct 6, 2020

For your comment (1), MenuComplete is part of PSReadLine, not the host. That means it won't be generally available to all applications that hosts PowerShell and thus won't be reliable for a module to use. Are you suggesting to move MenuComplete to PowerShell host?

PowerShell scripts and modules can and do frequently take dependencies on (particular versions of) Powershell modules, but rarely if ever rely on specific versions of the PowerShell host.

I am suggesting that this should be a command available in the PSReadLine module which could be called by other modules or scripts which take a dependency on (a future version of) that module. Modules are versioned, and generally backward compatible (and PSReadLine is, specifically, installable even down to Windows PowerShell), and are in my opinion inherently the right shipping container for most functionality.

@vexx32
Copy link

@vexx32 vexx32 commented Oct 6, 2020

Perhaps it'd be better if the UI functionality parts of PSRL is split out into a slightly more general-purpose module that can be used from PS and C# modules? That way, you could take a dependency on the UI portion without necessarily requiring PSRL itself to be loaded, and PSRL would just take that same dependency for the functionality it needs.

@Jaykul
Copy link
Author

@Jaykul Jaykul commented Oct 8, 2020

I don't think that's necessary, but I wouldn't argue against it. Remember though, that interactive "custom PowerShell hosts" that don't ship and depend on PSReadLine are purely hypothetical in nature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.
X Tutup