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

Implement autocompletion #96

Closed
wants to merge 23 commits into from
Closed

Conversation

mauricel
Copy link

@mauricel mauricel commented Mar 10, 2021

Demo pull request for #13 -- good enough to demo.

To try out, use this powershell snippet.

    $scriptblock = {
    param($wordToComplete, $commandAst, $cursorPosition)
        # assumes exe is not somewhere random on the path
        $command = ".\CliFx.Demo"

        &$command `[suggest`] $commandAst | ForEach-Object {
            [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
        }
}

Register-ArgumentCompleter -Native -CommandName CliFx.Demo -ScriptBlock $scriptblock

Still to do:

  • manual acceptance testing for powershell
  • manual acceptance testing for bash.

Not going to attempt to implement cursor positioning. Input provided by user might not match what is received by library.

1. System.IO.Environment.CommandLine and System.IO.Environment.GetCommandLineArgs() returned processed, escaped output, rendering cursor positioning meaningless.
2. Powershell does not pass "" delimited arguments unless they have been escaped (see https://stackoverflow.com/a/59681993/167733). This library does not force users to use powershell escapes, so suggestions shouldn't either.
…e to communicate that the property does not necessarily hold a validated Command
…nt. Parse autocompletion text as per Envrionment.GetCommandArgs().
@Tyrrrz Tyrrrz added the enhancement New feature or request label Mar 10, 2021
@Tyrrrz Tyrrrz changed the title #13 suggest mode !!do-not-merge [WIP] Implement autocompletion Mar 19, 2021
@mauricel mauricel closed this Mar 23, 2021
@mauricel mauricel deleted the #13-suggest-mode branch March 23, 2021 14:09
@Tyrrrz Tyrrrz changed the title [WIP] Implement autocompletion Implement autocompletion Mar 23, 2021
@Tyrrrz Tyrrrz removed the enhancement New feature or request label Mar 23, 2021
@Tyrrrz Tyrrrz added the invalid This doesn't seem right label Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants