omelette
omelette copied to clipboard
Windows support
Great tool, Is this suppose to work on windows with CMD, powershell or git bash?
We need to learn about completion system on PowerShell and CMD
Maybe we can try to understand these kind of projects: https://github.com/dahlbyk/posh-git/blob/master/src/GitTabExpansion.ps1
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])
}
}
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