1- import { filepaths } from '../../helpers/filepaths' ; import { keyValue } from '../../helpers/keyvalue' ;
1+ /*---------------------------------------------------------------------------------------------
2+ * Copyright (c) Microsoft Corporation. All rights reserved.
3+ * Licensed under the MIT License. See License.txt in the project root for license information.
4+ *--------------------------------------------------------------------------------------------*/
5+
6+ /* eslint-disable local/code-no-unexternalized-strings */
7+
8+ import * as vscode from 'vscode' ;
9+ import { filepaths } from '../helpers/filepaths' ;
10+ import { keyValue } from '../helpers/keyvalue' ;
211
312const filterMessages = ( out : string ) : string => {
413 return out . startsWith ( "warning:" ) || out . startsWith ( "error:" )
@@ -29,6 +38,7 @@ const postProcessRemoteBranches: Fig.Generator["postProcess"] = (out) => {
2938 name : elm . replace ( "*" , "" ) . trim ( ) ,
3039 description : "Current branch" ,
3140 priority : 100 ,
41+ // allow-any-unicode-next-line
3242 icon : "⭐️" ,
3343 } ;
3444 } else if ( parts [ 0 ] === "+" ) {
@@ -40,7 +50,7 @@ const postProcessRemoteBranches: Fig.Generator["postProcess"] = (out) => {
4050 return {
4151 name,
4252 description : "Branch" ,
43- icon : " vscode://icon?type=11" ,
53+ icon : ` vscode://icon?type=${ vscode . TerminalCompletionItemKind . Branch } ` ,
4454 priority : 75 ,
4555 } ;
4656 } ) ;
@@ -56,6 +66,7 @@ const listRepoMapFunction = (repo: RepoDataType) => ({
5666 name : repo . nameWithOwner ,
5767 description : repo . description ?? undefined ,
5868 //be able to see if the repo is private at a glance
69+ // allow-any-unicode-next-line
5970 icon : repo . isPrivate ? "🔒" : "👀" ,
6071} ) ;
6172
@@ -68,7 +79,9 @@ const ghGenerators: Record<string, Fig.Generator> = {
6879 const last = tokens . pop ( ) ;
6980
7081 //gatekeeper
71- if ( ! last ) return [ ] ;
82+ if ( ! last ) {
83+ return [ ] ;
84+ }
7285
7386 /**
7487 * this turns this input:
@@ -80,13 +93,17 @@ const ghGenerators: Record<string, Fig.Generator> = {
8093 const userRepoSplit = last . split ( "/" ) ;
8194
8295 // make sure it has some length.
83- if ( userRepoSplit . length === 0 ) return [ ] ;
96+ if ( userRepoSplit . length === 0 ) {
97+ return [ ] ;
98+ }
8499
85100 //get first element of arr
86101 const userOrOrg = userRepoSplit . shift ( ) ;
87102
88103 // make sure it has some existence.
89- if ( ! userOrOrg ) return [ ] ;
104+ if ( ! userOrOrg ) {
105+ return [ ] ;
106+ }
90107
91108 //run `gh repo list` cmd
92109 const { stdout, status } = await execute ( {
@@ -103,7 +120,9 @@ const ghGenerators: Record<string, Fig.Generator> = {
103120 } ) ;
104121
105122 // make sure it has some existence.
106- if ( status !== 0 ) return [ ] ;
123+ if ( status !== 0 ) {
124+ return [ ] ;
125+ }
107126
108127 //parse the JSON string output of the command
109128 const repoArr : RepoDataType [ ] = JSON . parse ( stdout ) ;
@@ -171,7 +190,7 @@ const ghGenerators: Record<string, Fig.Generator> = {
171190 name : number . toString ( ) ,
172191 displayName : title ,
173192 description : `#${ number } | ${ headRefName } ` ,
174- icon : state === "OPEN" ? "✅" : "☑️" ,
193+ icon : `vscode://icon?type= ${ state === "OPEN" ? vscode . TerminalCompletionItemKind . PullRequest : vscode . TerminalCompletionItemKind . PullRequestDone } ` ,
175194 } ;
176195 } ) ;
177196 } ,
@@ -319,27 +338,124 @@ const completionSpec: Fig.Spec = {
319338 ] ,
320339 } ,
321340 ] ,
341+ } , {
342+ name : "api" ,
343+ description : "Make an authenticated GitHub API request" ,
344+ args : {
345+ name : "<endpoint> [flags]a" ,
346+ } ,
347+ options : [
348+ {
349+ name : "--cache" ,
350+ description : 'Cache the response, e.g. "3600s", "60m", "1h"' ,
351+ args : { name : "duration" } ,
352+ } ,
353+ {
354+ name : [ "-F" , "--field" ] ,
355+ description : "Add a typed parameter in key=value format" ,
356+ args : { name : "key:value" } ,
357+ } ,
358+ {
359+ name : "--hostname" ,
360+ description :
361+ 'The GitHub hostname for the request (default "github.com")' ,
362+ args : {
363+ name : "string" ,
364+ } ,
365+ } ,
366+ {
367+ name : [ "-i" , "--include" ] ,
368+ description :
369+ "Include HTTP response status line and headers in the output" ,
370+ } ,
371+ {
372+ name : "--input" ,
373+ description :
374+ 'The file to use as body for the HTTP request (use "-" to read from standard input)' ,
375+ args : { name : "file" } ,
376+ } ,
377+ {
378+ name : [ "-q" , "--jq" ] ,
379+ description :
380+ "Query to select values from the response using jq syntax" ,
381+ args : { name : "string" } ,
382+ } ,
383+ {
384+ name : [ "-X" , "--method" ] ,
385+ description : "The HTTP method for the request" ,
386+ args : { name : "string" , description : '(default "GET")' } ,
387+ } ,
388+ {
389+ name : "--paginate" ,
390+ description :
391+ "Make additional HTTP requests to fetch all pages of results" ,
392+ } ,
393+ {
394+ name : [ "-p" , "--preview" ] ,
395+ description :
396+ 'GitHub API preview names to request (without the "-preview" suffix)' ,
397+ args : { name : "names" } ,
398+ } ,
399+ {
400+ name : [ "-f" , "--raw-field" ] ,
401+ description : "Add a string parameter in key=value format" ,
402+ args : { name : "key=value" } ,
403+ } ,
404+ {
405+ name : "--silent" ,
406+ description : "Do not print the response body" ,
407+ } ,
408+ {
409+ name : "--slurp" ,
410+ description :
411+ 'Use with "--paginate" to return an array of all pages of either JSON arrays or objects' ,
412+ } ,
413+ {
414+ name : [ "-t" , "--template" ] ,
415+ description :
416+ 'Format JSON output using a Go template; see "gh help formatting"' ,
417+ args : { name : "string" } ,
418+ } ,
419+ {
420+ name : "--verbose" ,
421+ description : "Include full HTTP request and response in the output" ,
422+ } ,
423+ ] ,
322424 } ,
323- { name : "api" , description : "Make an authenticated GitHub API request" } ,
324425 {
325426 name : "auth" ,
326- description : "Login, logout, and refresh your authentication " ,
427+ description : "Authenticate gh and git with GitHub " ,
327428
328429 subcommands : [
329430 {
330431 name : "login" ,
331- description : "Authenticate with a GitHub host " ,
432+ description : "Gh auth login [flags] " ,
332433 options : [
434+ {
435+ name : [ "-p" , "--git-protocol" ] ,
436+ description :
437+ "The protocol to use for git operations on this host: {ssh|https}" ,
438+ args : { name : "string" } ,
439+ } ,
333440 {
334441 name : [ "-h" , "--hostname" ] ,
335442 description :
336443 "The hostname of the GitHub instance to authenticate with" ,
337- args : { name : "hostname" } ,
444+ args : { name : "string" } ,
445+ } ,
446+ {
447+ name : "--insecure-storage" ,
448+ description :
449+ "Save authentication credentials in plain text instead of credential store" ,
338450 } ,
339451 {
340452 name : [ "-s" , "--scopes" ] ,
341- description : "Additional authentication scopes for gh to have" ,
342- args : { name : "scopes" } ,
453+ description : "Additional authentication scopes to request" ,
454+ args : { name : "strings" } ,
455+ } ,
456+ {
457+ name : "--skip-ssh-key" ,
458+ description : "Skip generate/upload SSH key prompt" ,
343459 } ,
344460 {
345461 name : [ "-w" , "--web" ] ,
@@ -348,65 +464,123 @@ const completionSpec: Fig.Spec = {
348464 {
349465 name : "--with-token" ,
350466 description : "Read token from standard input" ,
351- args : { name : "token" } ,
352467 } ,
353468 ] ,
354469 } ,
355470 {
356471 name : "logout" ,
357- description : "Log out of a GitHub host " ,
472+ description : "Gh auth logout [flags] " ,
358473 options : [
359474 {
360475 name : [ "-h" , "--hostname" ] ,
361- description :
362- "The hostname of the GitHub instance to authenticate with" ,
363- args : { name : "hostname" } ,
476+ description : "The hostname of the GitHub instance to log out of" ,
477+ args : { name : "string" } ,
478+ } ,
479+ {
480+ name : [ "-u" , "--user" ] ,
481+ description : "The account to log out of" ,
482+ args : { name : "string" } ,
364483 } ,
365484 ] ,
366485 } ,
367486 {
368487 name : "refresh" ,
369- description : "Refresh stored authentication credentials " ,
488+ description : "Gh auth refresh [flags] " ,
370489 options : [
371490 {
372491 name : [ "-h" , "--hostname" ] ,
492+ description : "The GitHub host to use for authentication" ,
493+ args : { name : "string" } ,
494+ } ,
495+ {
496+ name : "--insecure-storage" ,
373497 description :
374- "The hostname of the GitHub instance to authenticate with" ,
375- args : { name : "hostname" } ,
498+ "Save authentication credentials in plain text instead of credential store" ,
499+ } ,
500+ {
501+ name : [ "-r" , "--remove-scopes" ] ,
502+ description : "Authentication scopes to remove from gh" ,
503+ args : { name : "strings" } ,
504+ } ,
505+ {
506+ name : "--reset-scopes" ,
507+ description :
508+ "Reset authentication scopes to the default minimum set of scopes" ,
376509 } ,
377510 {
378511 name : [ "-s" , "--scopes" ] ,
379512 description : "Additional authentication scopes for gh to have" ,
380- args : { name : "scopes " } ,
513+ args : { name : "strings " } ,
381514 } ,
382515 ] ,
383516 } ,
384517 {
385518 name : "setup-git" ,
386- description : "Configure git to use GitHub CLI as a credential helper " ,
519+ description : "Gh auth setup- git [flags] " ,
387520 options : [
388521 {
389- name : [ "-h " , "--hostname " ] ,
522+ name : [ "-f " , "--force " ] ,
390523 description :
391- "The hostname of the GitHub instance to authenticate with" ,
392- args : { name : "hostname" } ,
524+ "Force setup even if the host is not known. Must be used in conjunction with --hostname" ,
525+ args : { name : "--hostname" } ,
526+ } ,
527+ {
528+ name : [ "-h" , "--hostname" ] ,
529+ description : "The hostname to configure git for" ,
530+ args : { name : "string" } ,
393531 } ,
394532 ] ,
395533 } ,
396534 {
397535 name : "status" ,
398536 description : "View authentication status" ,
537+ options : [
538+ {
539+ name : [ "-a" , "--active" ] ,
540+ description : "Display the active account only" ,
541+ } ,
542+ {
543+ name : [ "-h" , "--hostname" ] ,
544+ description : "Check only a specific hostname's auth status" ,
545+ args : { name : "string" } ,
546+ } ,
547+ {
548+ name : [ "-t" , "--show-token" ] ,
549+ description : "Display the auth token" ,
550+ } ,
551+ ] ,
552+ } ,
553+ {
554+ name : "switch" ,
555+ description : "Switch the active account for a GitHub host" ,
399556 options : [
400557 {
401558 name : [ "-h" , "--hostname" ] ,
402559 description :
403- "The hostname of the GitHub instance to authenticate with " ,
404- args : { name : "hostname " } ,
560+ "The hostname of the GitHub instance to switch account for " ,
561+ args : { name : "string " } ,
405562 } ,
406563 {
407- name : "--with-token" ,
408- description : "Read token from standard input" ,
409- args : { name : "token" } ,
564+ name : [ "-u" , "--user" ] ,
565+ description : "The account to switch to" ,
566+ args : { name : "string" } ,
567+ } ,
568+ ] ,
569+ } ,
570+ {
571+ name : "token" ,
572+ description : "Gh auth token [flags]" ,
573+ options : [
574+ {
575+ name : [ "-h" , "--hostname" ] ,
576+ description :
577+ "The hostname of the GitHub instance authenticated with" ,
578+ args : { name : "string" } ,
579+ } ,
580+ {
581+ name : [ "-u" , "--user" ] ,
582+ description : "The account to output the token for" ,
583+ args : { name : "string" } ,
410584 } ,
411585 ] ,
412586 } ,
@@ -1574,8 +1748,8 @@ Pass additional 'git clone' flags by listing them after '--'`,
15741748To create a repository interactively, use 'gh repo create' with no arguments.
15751749To create a remote repository non-interactively, supply the repository name and one of '--public', '--private', or '--internal'.
15761750Pass '--clone' to clone the new repository locally.
1577- To create a remote repository from an existing local repository, specify the source directory with '--source'.
1578- By default, the remote repository name will be the name of the source directory.
1751+ To create a remote repository from an existing local repository, specify the source directory with '--source'.
1752+ By default, the remote repository name will be the name of the source directory.
15791753Pass '--push' to push any local commits to the new repository` ,
15801754 args : {
15811755 name : "name" ,
@@ -1726,7 +1900,7 @@ Pass '--push' to push any local commits to the new repository`,
17261900 name : "delete" ,
17271901 description : `Delete a GitHub repository.
17281902With no argument, deletes the current repository. Otherwise, deletes the specified repository.
1729- Deletion requires authorization with the "delete_repo" scope.
1903+ Deletion requires authorization with the "delete_repo" scope.
17301904To authorize, run "gh auth refresh -s delete_repo"` ,
17311905 isDangerous : true ,
17321906 args : {
@@ -2003,7 +2177,7 @@ By default, this renames the current repository; otherwise renames the specified
20032177of the source repository to update the matching branch on the destination
20042178repository so they are equal. A fast forward update will be used execept when the
20052179'--force' flag is specified, then the two branches will
2006- by synced using a hard reset.
2180+ by synced using a hard reset.
20072181Without an argument, the local repository is selected as the destination repository.
20082182The source repository is the parent of the destination repository by default.
20092183This can be overridden with the '--source' flag` ,
0 commit comments