You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tab-completions for powershell don't work on the root command #1775
[CompletionResult]::new tooltip param can't use empty string.
~
❯ gh --version
gh version 1.0.0 (2020-09-16)
https://github.com/cli/cli/releases/tag/v1.0.0
~
❯ $PSVersionTable
Name Value
---------
PSVersion 7.1.0-preview.7
PSEdition Core
GitCommitId 7.1.0-preview.7
OS Microsoft Windows 10.0.19041
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
~
❯ usingnamespaceSystem.Management.Automation>>usingnamespaceSystem.Management.Automation.Language>>>> [CompletionResult]::new('--help','help', [CompletionResultType]::ParameterName,'Show help for command')
>> [CompletionResult]::new('--version','version', [CompletionResultType]::ParameterName,'Show gh version')
>> [CompletionResult]::new('alias','alias', [CompletionResultType]::ParameterValue,'Create command shortcuts')
>> [CompletionResult]::new('api','api', [CompletionResultType]::ParameterValue,'Make an authenticated GitHub API request')
>> [CompletionResult]::new('auth','auth', [CompletionResultType]::ParameterValue,'Login, logout, and refresh your authentication')
>> [CompletionResult]::new('completion','completion', [CompletionResultType]::ParameterValue,'Generate shell completion scripts')
>> [CompletionResult]::new('config','config', [CompletionResultType]::ParameterValue,'Manage configuration for gh')
>> [CompletionResult]::new('credits','credits', [CompletionResultType]::ParameterValue,'View credits for this tool')
>> [CompletionResult]::new('environment','environment', [CompletionResultType]::ParameterValue,'')
>> [CompletionResult]::new('gist','gist', [CompletionResultType]::ParameterValue,'Create gists')
>> [CompletionResult]::new('help','help', [CompletionResultType]::ParameterValue,'Help about any command')
>> [CompletionResult]::new('issue','issue', [CompletionResultType]::ParameterValue,'Manage issues')
>> [CompletionResult]::new('pr','pr', [CompletionResultType]::ParameterValue,'Manage pull requests')
>> [CompletionResult]::new('release','release', [CompletionResultType]::ParameterValue,'Manage GitHub releases')
>> [CompletionResult]::new('repo','repo', [CompletionResultType]::ParameterValue,'Create, clone, fork, and view repositories')
>> [CompletionResult]::new('version','version', [CompletionResultType]::ParameterValue,'')
CompletionText ListItemText ResultType ToolTip
---------------------------------------------help help ParameterName Show help for command
--version version ParameterName Show gh version
alias alias ParameterValue Create command shortcuts
api api ParameterValue Make an authenticated GitHub API request
auth auth ParameterValue Login, logout, and refresh your authentication
completion completion ParameterValue Generate shell completion scripts
config config ParameterValue Manage configuration for gh
credits credits ParameterValue View credits for this tool
MethodInvocationException:
Line |12| [CompletionResult]::new('environment','environment', [Co …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|Exceptioncalling".ctor"with"4"argument(s): "Cannot process argument because the value of argument "toolTip" is null. Change the value of argument "toolTip" to a non-null value."gistgistParameterValueCreategistshelphelpParameterValueHelpaboutanycommandissueissueParameterValueManageissuesprprParameterValueManagepullrequestsreleasereleaseParameterValueManageGitHubreleasesreporepoParameterValueCreate,clone,fork,andviewrepositoriesMethodInvocationException:
Line|19| [CompletionResult]::new('version','version', [Completion …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|Exceptioncalling".ctor"with"4"argument(s): "Cannot process argument because the value of argument "toolTip" is null. Change the value of argument "toolTip" to a non-null value."
If set whitespace, ti works.
~
❯ usingnamespaceSystem.Management.Automation>>usingnamespaceSystem.Management.Automation.Language>>>> [CompletionResult]::new('version','version', [CompletionResultType]::ParameterValue,'')
>> [CompletionResult]::new('version','version', [CompletionResultType]::ParameterValue,'')
MethodInvocationException:
Line |4| [CompletionResult]::new('version','version', [CompletionResultType]: …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling ".ctor" with "4" argument(s): "Cannot process argument because the value of argument "toolTip" is null. Change the value of argument "toolTip" to a non-null value."
CompletionText ListItemText ResultType ToolTip
-------------------------------------------
version version ParameterValue
This bug occurs on Linux as well.
Probably the same on MacOS.
PS /root>usingnamespaceSystem.Management.Automation>>usingnamespaceSystem.Management.Automation.Language>>>>$PSVersionTable>>>> [CompletionResult]::new('version','version', [CompletionResultType]::ParameterValue,'')
>> [CompletionResult]::new('version','version', [CompletionResultType]::ParameterValue,'')
Name Value
---------
PSVersion 7.1.0-preview.5
PSEdition Core
GitCommitId 7.1.0-preview.5
OS Linux 4.19.104-microsoft-standard #1 SMP Wed Feb 19 06:37:35 UTC 2020
Platform Unix
PSCompatibleVersions {1.0,2.0,3.0,4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
MethodInvocationException:
Line |6| [CompletionResult]::new('version','version', [CompletionResultType]: …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling ".ctor" with "4" argument(s): "Cannot process argument because the value of argument "toolTip" is null. Change the value of argument "toolTip" to a non-null value."
CompletionText : version
ListItemText : version
ResultType : ParameterValue
ToolTip :
In my case, Fix environment and version 's CompletionResult constructor, it works!!
~
❯ gh completion -s powershell > temp:/GitHubCliCompletion.ps1
~
❯ # Fixed Empty stirng to Whitepace script>>. Temp:\GitHubCliCompletion.ps1
~
❯ # works!!>> gh issue
alias api auth completion config credits environment gist help issue pr release repo version
Manage issues
Fortunately, this bug is avoidable if only it is known to exist.
Until this bug is fixed, I think it's reasonable to write the following in the Profile.
This Issue's bug will be fixed in spf13/cobra#1208 (comment)
However, it's not yet tested whether you will be able to complete the tabs for partial words.
If there is someone who is familiar with Powershell and Go lang, please check it and it may help me to solve the bug.
I found 2 errors in the powershell completion script generated from gh completion --shell powershell - gh version 1.4.0
The first with [CompletionResult]::new('version', 'version', [CompletionResultType]::ParameterValue, ''), the tooltip part cannot be empty,
The second occurring when single quotes are used around backticks, as of v1.4.0 I found 31 lines with single quotes around backticks.
One example is ( " - is substituted for the backticks) - [CompletionResult]::new('-a', 'a', [CompletionResultType]::ParameterName, 'Assign people by their "login"')
This thread has dragged on a bit with various recommendations. Currently, what should we add to our powershell profile to enable completions?
There are a few ways, if you want to grab the gist I posted you can use this - Invoke-Expression -Command ([System.Net.WebClient]::new().DownloadString('https://gist.githubusercontent.com/WozNet/fcf17f71452ab9efeeb17765694b1797/raw'))
I would avoid using the code generated from - gh completion --shell powershell until they fix the issues I mentioned above. The error with 'version' means that entire grouping of commands (alias, auth, config, etc..) won't work, and the backticks in single quotes causes there own issues.
Activity
mislav commentedon Sep 18, 2020
Thank you for reporting!
SilkyFowl commentedon Sep 18, 2020
[CompletionResult]::newtooltip param can't use empty string.If set whitespace, ti works.
This bug occurs on Linux as well.
Probably the same on MacOS.
In my case, Fix
environmentandversion's CompletionResult constructor, it works!!SilkyFowl commentedon Sep 18, 2020
I got the following to work:
mislav commentedon Sep 18, 2020
@SilkyFowl Thank you for looking into all of this! ❤️
Our PowerShell completions are being generated by Cobra https://github.com/spf13/cobra/blob/master/powershell_completions.go
vilmibm commentedon Sep 18, 2020
Is this a cobra bug, then, or something we have control over?
SilkyFowl commentedon Sep 19, 2020
Should I open Issue to Cobra?
I'll have to run some errands, so I'll probably be back in half a day or so...
SilkyFowl commentedon Sep 20, 2020
@vilmibm I think so, too.
So I opened Issue to Cobra. spf13/cobra/issues/1229
Fortunately, this bug is avoidable if only it is known to exist.
Until this bug is fixed, I think it's reasonable to write the following in the Profile.
If the pipeline is to be used, write this
strickdd commentedon Oct 9, 2020
Is there a way to get partially typed words to be tab-completed?
For example:
gh pr ch<tab>Should cycle through the following as is pressed multiple times:
gh pr checkoutand
gh pr checksRight now, it doesn't complete anything.
SilkyFowl commentedon Oct 10, 2020
@strickdd
I was able to reproduce it in my environment.
After a lot of testing, I also found that I could avoid the error by doing this.
However, a side-effect of the code is that it causes a bug in the tail completion.
Expected
Actual
I was unsure, but I decided to put this code in
$profileto see which would be more inconvenient.SilkyFowl commentedon Oct 10, 2020
This Issue's bug will be fixed in spf13/cobra#1208 (comment)
However, it's not yet tested whether you will be able to complete the tabs for partial words.
If there is someone who is familiar with Powershell and Go lang, please check it and it may help me to solve the bug.
Luap99 commentedon Oct 23, 2020
Note: This is not fixed in cobra v1.1.1
mislav commentedon Oct 23, 2020
@Luap99 Thanks for the heads-up!
woznet commentedon Dec 8, 2020
I made a few edits which made this a lot more workable for me, I posted the changes here - https://gist.github.com/Woznet/fcf17f71452ab9efeeb17765694b1797
I found 2 errors in the powershell completion script generated from
gh completion --shell powershell- gh version 1.4.0The first with
[CompletionResult]::new('version', 'version', [CompletionResultType]::ParameterValue, ''), the tooltip part cannot be empty,The second occurring when single quotes are used around backticks, as of v1.4.0 I found 31 lines with single quotes around backticks.
One example is ( " - is substituted for the backticks) -
[CompletionResult]::new('-a', 'a', [CompletionResultType]::ParameterName, 'Assign people by their "login"')musm commentedon Dec 23, 2020
This thread has dragged on a bit with various recommendations. Currently, what should we add to our powershell profile to enable completions?
just1a-person commentedon Dec 23, 2020
nit: This issue is labeled "Windows". But PowerShell is cross-platform
woznet commentedon Dec 24, 2020
There are a few ways, if you want to grab the gist I posted you can use this -
Invoke-Expression -Command ([System.Net.WebClient]::new().DownloadString('https://gist.githubusercontent.com/WozNet/fcf17f71452ab9efeeb17765694b1797/raw'))I would avoid using the code generated from -
gh completion --shell powershelluntil they fix the issues I mentioned above. The error with 'version' means that entire grouping of commands (alias, auth, config, etc..) won't work, and the backticks in single quotes causes there own issues.mislav commentedon May 10, 2022
I cannot reproduce with latest GitHub CLI version. We've upgraded Cobra in the meantime; this must have fixed it!