From d156e8e276b05a7fb71aa73db7df53b8ae2a3c0c Mon Sep 17 00:00:00 2001 From: hacker65536 Date: Tue, 29 Apr 2025 18:43:36 +0900 Subject: [PATCH 1/2] feat(gh): update spec --- src/gh.ts | 206 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 181 insertions(+), 25 deletions(-) diff --git a/src/gh.ts b/src/gh.ts index 9dc0dd09b3b6..10879c23b294 100644 --- a/src/gh.ts +++ b/src/gh.ts @@ -320,26 +320,124 @@ const completionSpec: Fig.Spec = { }, ], }, - { name: "api", description: "Make an authenticated GitHub API request" }, + { + name: "api", + description: "Make an authenticated GitHub API request", + args: { + name: " [flags]a", + }, + options: [ + { + name: "--cache", + description: 'Cache the response, e.g. "3600s", "60m", "1h"', + args: { name: "duration" }, + }, + { + name: ["-F", "--field"], + description: "Add a typed parameter in key=value format", + args: { name: "key:value" }, + }, + { + name: "--hostname", + description: + 'The GitHub hostname for the request (default "github.com")', + args: { + name: "string", + }, + }, + { + name: ["-i", "--include"], + description: + "Include HTTP response status line and headers in the output", + }, + { + name: "--input", + description: + 'The file to use as body for the HTTP request (use "-" to read from standard input)', + args: { name: "file" }, + }, + { + name: ["-q", "--jq"], + description: + "Query to select values from the response using jq syntax", + args: { name: "string" }, + }, + { + name: ["-X", "--method"], + description: "The HTTP method for the request", + args: { name: "string", description: '(default "GET")' }, + }, + { + name: "--paginate", + description: + "Make additional HTTP requests to fetch all pages of results", + }, + { + name: ["-p", "--preview"], + description: + 'GitHub API preview names to request (without the "-preview" suffix)', + args: { name: "names" }, + }, + { + name: ["-f", "--raw-field"], + description: "Add a string parameter in key=value format", + args: { name: "key=value" }, + }, + { + name: "--silent", + description: "Do not print the response body", + }, + { + name: "--slurp", + description: + 'Use with "--paginate" to return an array of all pages of either JSON arrays or objects', + }, + { + name: ["-t", "--template"], + description: + 'Format JSON output using a Go template; see "gh help formatting"', + args: { name: "string" }, + }, + { + name: "--verbose", + description: "Include full HTTP request and response in the output", + }, + ], + }, { name: "auth", - description: "Login, logout, and refresh your authentication", + description: "Authenticate gh and git with GitHub", subcommands: [ { name: "login", - description: "Authenticate with a GitHub host", + description: "Gh auth login [flags]", options: [ + { + name: ["-p", "--git-protocol"], + description: + "The protocol to use for git operations on this host: {ssh|https}", + args: { name: "string" }, + }, { name: ["-h", "--hostname"], description: "The hostname of the GitHub instance to authenticate with", - args: { name: "hostname" }, + args: { name: "string" }, + }, + { + name: "--insecure-storage", + description: + "Save authentication credentials in plain text instead of credential store", }, { name: ["-s", "--scopes"], - description: "Additional authentication scopes for gh to have", - args: { name: "scopes" }, + description: "Additional authentication scopes to request", + args: { name: "strings" }, + }, + { + name: "--skip-ssh-key", + description: "Skip generate/upload SSH key prompt", }, { name: ["-w", "--web"], @@ -348,65 +446,123 @@ const completionSpec: Fig.Spec = { { name: "--with-token", description: "Read token from standard input", - args: { name: "token" }, }, ], }, { name: "logout", - description: "Log out of a GitHub host", + description: "Gh auth logout [flags]", options: [ { name: ["-h", "--hostname"], - description: - "The hostname of the GitHub instance to authenticate with", - args: { name: "hostname" }, + description: "The hostname of the GitHub instance to log out of", + args: { name: "string" }, + }, + { + name: ["-u", "--user"], + description: "The account to log out of", + args: { name: "string" }, }, ], }, { name: "refresh", - description: "Refresh stored authentication credentials", + description: "Gh auth refresh [flags]", options: [ { name: ["-h", "--hostname"], + description: "The GitHub host to use for authentication", + args: { name: "string" }, + }, + { + name: "--insecure-storage", description: - "The hostname of the GitHub instance to authenticate with", - args: { name: "hostname" }, + "Save authentication credentials in plain text instead of credential store", + }, + { + name: ["-r", "--remove-scopes"], + description: "Authentication scopes to remove from gh", + args: { name: "strings" }, + }, + { + name: "--reset-scopes", + description: + "Reset authentication scopes to the default minimum set of scopes", }, { name: ["-s", "--scopes"], description: "Additional authentication scopes for gh to have", - args: { name: "scopes" }, + args: { name: "strings" }, }, ], }, { name: "setup-git", - description: "Configure git to use GitHub CLI as a credential helper", + description: "Gh auth setup-git [flags]", options: [ { - name: ["-h", "--hostname"], + name: ["-f", "--force"], description: - "The hostname of the GitHub instance to authenticate with", - args: { name: "hostname" }, + "Force setup even if the host is not known. Must be used in conjunction with --hostname", + args: { name: "--hostname" }, + }, + { + name: ["-h", "--hostname"], + description: "The hostname to configure git for", + args: { name: "string" }, }, ], }, { name: "status", description: "View authentication status", + options: [ + { + name: ["-a", "--active"], + description: "Display the active account only", + }, + { + name: ["-h", "--hostname"], + description: "Check only a specific hostname's auth status", + args: { name: "string" }, + }, + { + name: ["-t", "--show-token"], + description: "Display the auth token", + }, + ], + }, + { + name: "switch", + description: "Switch the active account for a GitHub host", options: [ { name: ["-h", "--hostname"], description: - "The hostname of the GitHub instance to authenticate with", - args: { name: "hostname" }, + "The hostname of the GitHub instance to switch account for", + args: { name: "string" }, }, { - name: "--with-token", - description: "Read token from standard input", - args: { name: "token" }, + name: ["-u", "--user"], + description: "The account to switch to", + args: { name: "string" }, + }, + ], + }, + { + name: "token", + description: "Gh auth token [flags]", + options: [ + { + name: ["-h", "--hostname"], + description: + "The hostname of the GitHub instance authenticated with", + args: { name: "string" }, + }, + { + name: ["-u", "--user"], + description: "The account to output the token for", + args: { name: "string" }, }, ], }, @@ -429,7 +585,7 @@ const completionSpec: Fig.Spec = { }, { name: "browse", - description: "Open the repository in the browser", + description: "Open the repository in the browsera", args: { name: "[pr | issue | path[:line]", generators: ghGenerators.listPR, From 706282e25bee0c08870a07416af8bbb77a3d0778 Mon Sep 17 00:00:00 2001 From: hacker65536 Date: Tue, 20 May 2025 08:14:54 +0900 Subject: [PATCH 2/2] Update src/gh.ts Co-authored-by: Chay Nabors --- src/gh.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gh.ts b/src/gh.ts index 10879c23b294..98a781674655 100644 --- a/src/gh.ts +++ b/src/gh.ts @@ -585,7 +585,7 @@ const completionSpec: Fig.Spec = { }, { name: "browse", - description: "Open the repository in the browsera", + description: "Open the repository in the browser", args: { name: "[pr | issue | path[:line]", generators: ghGenerators.listPR,