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 auto path completion for Read-Host #15199

Closed
Andy-AO opened this issue Apr 11, 2021 · 6 comments
Closed

Add auto path completion for Read-Host #15199

Andy-AO opened this issue Apr 11, 2021 · 6 comments
Labels
Issue-Enhancement the issue is more of a feature request than a bug Needs-Triage The issue is new and needs to be triaged by a work group. Resolution-No Activity Issue has had no activity for 6 months or more WG-Interactive-IntelliSense tab completion

Comments

@Andy-AO
Copy link

Andy-AO commented Apr 11, 2021

The PowerShell function being written to generate folders based on templates.

It has a "target path" parameter that is expected to be a subdirectory of a specific directory, so it wants to provide the user with a path completion basis, but there is no such completion mechanism in the Read-Host state.

Although there is a completion mechanism when entering the parameters, the working directory does not change at that time, so the user has to switch the working directory manually, which makes the experience very bad.

CMD has this feature, but PowerShell does not, so this is a problem.

Looking at StackOverFlow, a temporary solution was found to use the GUI, but this has a lot of problems and doesn't work in many cases.

A similar issue has been found, but this issue already has an alternative method, and the path completion seems to have not.

@Andy-AO Andy-AO added Issue-Enhancement the issue is more of a feature request than a bug Needs-Triage The issue is new and needs to be triaged by a work group. labels Apr 11, 2021
@Andy-AO
Copy link
Author

Andy-AO commented Apr 11, 2021

The code ↓

function New-FolderBaseTemplate {
    param (
        [Parameter()]
        [ValidateSet("PyCharm")]
        [String]
        $ActionName,
        [Parameter()]
        [String]
        $InstanceName
    )
    if($ActionName -eq "PyCharm"){
        $TargetRootLocation  = 'D:\MyDocs\pycharm_pro'
        Set-Location $TargetRootLocation
        $TargetLocation = Read-Host 'Please select directory.'
        $params = @{
            NewInstanceName = $InstanceName
            TargetLocation  = $TargetLocation
            TemplatePath    = "$TargetLocation\.template"
        }
        NewFolderFromTemplate @params
    }
}

@mklement0
Copy link
Contributor

While not specifically about tab-completion, PowerShell/PSReadLine#881 proposes making Read-Host use an enhanced PSConsoleHostReadLine function by default; the latter is highly customizable (adding syntactic sugar for tab-completion functionality is conceivable).

@iSazonov iSazonov added the WG-Interactive-IntelliSense tab completion label Apr 12, 2021
Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

2 similar comments
Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

@microsoft-github-policy-service microsoft-github-policy-service bot added Resolution-No Activity Issue has had no activity for 6 months or more labels Nov 16, 2023
Copy link
Contributor

This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement the issue is more of a feature request than a bug Needs-Triage The issue is new and needs to be triaged by a work group. Resolution-No Activity Issue has had no activity for 6 months or more WG-Interactive-IntelliSense tab completion
Projects
None yet
Development

No branches or pull requests

3 participants