omelette icon indicating copy to clipboard operation
omelette copied to clipboard

Windows support

Open deepu105 opened this issue 9 years ago • 4 comments
trafficstars

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

deepu105 avatar Feb 19 '16 00:02 deepu105

We need to learn about completion system on PowerShell and CMD

f avatar Mar 06 '16 09:03 f

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

f avatar Oct 05 '17 21:10 f

I described how to implement this on yargs' issue tracker a couple years ago: https://github.com/yargs/yargs/issues/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])
    }
}

cspotcode avatar Dec 17 '20 22:12 cspotcode

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

iKrishnaSahu avatar Jan 13 '23 10:01 iKrishnaSahu