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

✨ add completion to gh pr checkout <tab> #714

Merged
merged 2 commits into from
Dec 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 37 additions & 28 deletions custom-completions/gh/gh-completions.nu
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
def "nu-complete gh" [] {
^gh --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand All @@ -16,7 +16,7 @@ export extern "gh" [
def "nu-complete gh auth" [] {
^gh auth --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand All @@ -43,7 +43,7 @@ export extern "gh browse" [
def "nu-complete gh codespace" [] {
^gh codespace --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand All @@ -57,7 +57,7 @@ export extern "gh codespace" [
def "nu-complete gh gist" [] {
^gh gist --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand All @@ -71,7 +71,7 @@ export extern "gh gist" [
def "nu-complete gh issue" [] {
^gh issue --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand All @@ -86,7 +86,7 @@ export extern "gh issue" [
def "nu-complete gh org" [] {
^gh org --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand All @@ -98,12 +98,7 @@ export extern "gh org" [
]

def "nu-complete gh pr" [] {
^gh pr --help
| lines
| filter {|line| str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
^gh pr --help | lines | filter { str starts-with " " } | skip 1 | parse "{value}: {description}" | str trim
}

export extern "gh pr" [
Expand All @@ -112,10 +107,24 @@ export extern "gh pr" [
--help # Show help for command
]

def "nu-complete gh list prs" [] {
gh pr list --json title,number,author,updatedAt | from json | update author {|row| $row.author.login } | rename --column { number: value } | insert description { |row| ( $row.updatedAt | date humanize) + " - " + $row.title + " by " + $row.author } | select value description
}

export extern "gh pr checkout" [
branch_url_or_PRnumber: string@"nu-complete gh list prs" # {<number> | <url> | <branch>}
--branch(-b): string # Local branch name to use (default: the name of the head branch)
--detach # Checkout PR with a detached HEAD
--force(-f) # Reset the existing local branch to the latest state of the pull request
--recurse-submodules # Update all submodules after checkout
--repo(-R) # Select another repository using the [HOST/]OWNER/REPO format
--help # Show help for command
]

def "nu-complete gh project" [] {
^gh project --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand All @@ -129,7 +138,7 @@ export extern "gh project" [
def "nu-complete gh release" [] {
^gh release --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand All @@ -144,7 +153,7 @@ export extern "gh release" [
def "nu-complete gh repo" [] {
^gh repo --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand Down Expand Up @@ -213,7 +222,7 @@ export extern "gh repo fork" [
def "nu-complete gh cache" [] {
^gh cache --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand All @@ -228,7 +237,7 @@ export extern "gh cache" [
def "nu-complete gh run" [] {
^gh run --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand All @@ -242,7 +251,7 @@ export extern "gh run" [
def "nu-complete gh workflow" [] {
^gh workflow --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand All @@ -257,7 +266,7 @@ export extern "gh workflow" [
def "nu-complete gh alias" [] {
^gh alias --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand Down Expand Up @@ -306,7 +315,7 @@ export extern "gh completion" [
def "nu-complete gh config" [] {
^gh config --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand All @@ -320,7 +329,7 @@ export extern "gh config" [
def "nu-complete gh extension" [] {
^gh extension --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand All @@ -334,7 +343,7 @@ export extern "gh extension" [
def "nu-complete gh gpg-key" [] {
^gh gpg-key --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand All @@ -348,7 +357,7 @@ export extern "gh gpg-key" [
def "nu-complete gh label" [] {
^gh label --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand All @@ -363,7 +372,7 @@ export extern "gh label" [
def "nu-complete gh ruleset" [] {
^gh ruleset --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand All @@ -378,7 +387,7 @@ export extern "gh ruleset" [
def "nu-complete gh search" [] {
^gh search --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand All @@ -404,7 +413,7 @@ export extern "gh search" [
def "nu-complete gh secret" [] {
^gh secret --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand All @@ -419,7 +428,7 @@ export extern "gh secret" [
def "nu-complete gh ssh-key" [] {
^gh ssh-key --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand All @@ -440,7 +449,7 @@ export extern "gh status" [
def "nu-complete gh variable" [] {
^gh variable --help
| lines
| filter {|line| str starts-with " " }
| filter { str starts-with " " }
| skip 1
| parse "{value}: {description}"
| str trim
Expand Down