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

Windows support #6

Open
deepu105 opened this issue Feb 19, 2016 · 4 comments
Open

Windows support #6

deepu105 opened this issue Feb 19, 2016 · 4 comments

Comments

@deepu105
Copy link

Great tool, Is this suppose to work on windows with CMD, powershell or git bash?

@f
Copy link
Owner

f commented Mar 6, 2016

We need to learn about completion system on PowerShell and CMD

@f
Copy link
Owner

f commented Oct 5, 2017

Maybe we can try to understand these kind of projects: https://github.com/dahlbyk/posh-git/blob/master/src/GitTabExpansion.ps1

@cspotcode
Copy link

cspotcode commented Dec 17, 2020

I described how to implement this on yargs' issue tracker a couple years ago: yargs/yargs#1290

PowerShell has built-in JSON serialization & parsing, so interop is easy: PowerShell sends you JSON, you reply with a JSON array. This keeps all the logic in JS, with a very minimal JSON adapter written as a short PowerShell function.

You can see in the snippet below, CompletionResults are richer than plain strings. The fields are described here: https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.completionresult?view=powershellsdk-7.0.0 This is related to #46

Register-ArgumentCompleter -Native -CommandName tabtab-test -ScriptBlock {
    $argsEncoded = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes(($args | convertto-json)))
    $results = yargs-command completion -- $argsEncoded | convertfrom-json
    foreach($result in $results) {
        [Management.Automation.CompletionResult]::new($result[0], $result[1], $result[2], $result[3])
    }
}

@iKrishnaSahu
Copy link

iKrishnaSahu commented Jan 13, 2023

Does this library works with GIT bash for Windows?

I tried it but facing some issue while running command.

I wrote a script which is inspired from the docs -

const omelette = require('omelette');

const firstArgument = ({ reply }) => {
    reply(['beautiful', 'cruel', 'far'])
}

const planet = ({ reply }) => {
    reply(['world', 'mars', 'pluto'])
}

const demo = omelette`hello|hi ${firstArgument} ${planet}`

demo.init();

demo.setupShellInitFile();

and then I ran this script. It created a .hello folder inside user directory and inside that folder, it created completion.sh

I restarted the git bash and checked if auto completion is working or not but I am getting some error -

e*******@****-***** MINGW64 /c/Projects/projects/angular nws/test/angular-ivy-6qh2wm
$ hi bash: hello: command not found
bash: __ltrim_colon_completions: command not found
e*******@****-***** MINGW64 /c/Projects/projects/angular nws/test/angular-ivy-6qh2wm
$ hello bash: hello: command not found
bash: __ltrim_colon_completions: command not found

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

No branches or pull requests

4 participants