hasura / graphql-engine

Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
https://hasura.io
Apache License 2.0
31.18k stars 2.77k forks source link

Add powershell 7 support to hasura completion #7668

Open BenoitRanque opened 3 years ago

BenoitRanque commented 3 years ago

Hasura completion currently supports bash and zsh.

Tab completion is now possible in powershell, with Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete

There is also the Register-ArgumentCompleter cmdlet which could be used to implement this.

Hasura's completion should include this shell.

stevebelskie commented 3 years ago

It looks like current completion is being done just through leveraging cobra's built-in completion functionality.

https://github.com/hasura/graphql-engine/blob/504f13725fb7a92de8159523b836aa5fcbd3e6ce/cli/commands/completion.go#L77-L98

Given that, is this change much more complicated than just adding a case statement like the following (and updating completionCmdExample?

    case "pwsh": 
        if o.File != "" { 
            err = o.Cmd.Root().GenPowerShellCompletionFile(o.File) 
        } else { 
            err = o.Cmd.Root().GenPowerShellCompletion(os.Stdout) 
        } 

If so, I'd be happy to contribute a PR to take care of this.