3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
- import { filepaths } from '../../helpers/filepaths' ;
7
- import { keyValue } from '../../helpers/keyvalue' ;
6
+ /* eslint-disable local/code-no-unexternalized-strings */
7
+
8
+ import { filepaths } from '../helpers/filepaths' ;
9
+ import { keyValue } from '../helpers/keyvalue' ;
8
10
9
11
const filterMessages = ( out : string ) : string => {
10
12
return out . startsWith ( "warning:" ) || out . startsWith ( "error:" )
@@ -35,6 +37,7 @@ const postProcessRemoteBranches: Fig.Generator["postProcess"] = (out) => {
35
37
name : elm . replace ( "*" , "" ) . trim ( ) ,
36
38
description : "Current branch" ,
37
39
priority : 100 ,
40
+ // allow-any-unicode-next-line
38
41
icon : "⭐️" ,
39
42
} ;
40
43
} else if ( parts [ 0 ] === "+" ) {
@@ -62,6 +65,7 @@ const listRepoMapFunction = (repo: RepoDataType) => ({
62
65
name : repo . nameWithOwner ,
63
66
description : repo . description ?? undefined ,
64
67
//be able to see if the repo is private at a glance
68
+ // allow-any-unicode-next-line
65
69
icon : repo . isPrivate ? "🔒" : "👀" ,
66
70
} ) ;
67
71
@@ -74,7 +78,9 @@ const ghGenerators: Record<string, Fig.Generator> = {
74
78
const last = tokens . pop ( ) ;
75
79
76
80
//gatekeeper
77
- if ( ! last ) return [ ] ;
81
+ if ( ! last ) {
82
+ return [ ] ;
83
+ }
78
84
79
85
/**
80
86
* this turns this input:
@@ -86,13 +92,17 @@ const ghGenerators: Record<string, Fig.Generator> = {
86
92
const userRepoSplit = last . split ( "/" ) ;
87
93
88
94
// make sure it has some length.
89
- if ( userRepoSplit . length === 0 ) return [ ] ;
95
+ if ( userRepoSplit . length === 0 ) {
96
+ return [ ] ;
97
+ }
90
98
91
99
//get first element of arr
92
100
const userOrOrg = userRepoSplit . shift ( ) ;
93
101
94
102
// make sure it has some existence.
95
- if ( ! userOrOrg ) return [ ] ;
103
+ if ( ! userOrOrg ) {
104
+ return [ ] ;
105
+ }
96
106
97
107
//run `gh repo list` cmd
98
108
const { stdout, status } = await execute ( {
@@ -109,7 +119,9 @@ const ghGenerators: Record<string, Fig.Generator> = {
109
119
} ) ;
110
120
111
121
// make sure it has some existence.
112
- if ( status !== 0 ) return [ ] ;
122
+ if ( status !== 0 ) {
123
+ return [ ] ;
124
+ }
113
125
114
126
//parse the JSON string output of the command
115
127
const repoArr : RepoDataType [ ] = JSON . parse ( stdout ) ;
@@ -177,6 +189,7 @@ const ghGenerators: Record<string, Fig.Generator> = {
177
189
name : number . toString ( ) ,
178
190
displayName : title ,
179
191
description : `#${ number } | ${ headRefName } ` ,
192
+ // allow-any-unicode-next-line
180
193
icon : state === "OPEN" ? "✅" : "☑️" ,
181
194
} ;
182
195
} ) ;
@@ -325,27 +338,124 @@ const completionSpec: Fig.Spec = {
325
338
] ,
326
339
} ,
327
340
] ,
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
+ ] ,
328
424
} ,
329
- { name : "api" , description : "Make an authenticated GitHub API request" } ,
330
425
{
331
426
name : "auth" ,
332
- description : "Login, logout, and refresh your authentication " ,
427
+ description : "Authenticate gh and git with GitHub " ,
333
428
334
429
subcommands : [
335
430
{
336
431
name : "login" ,
337
- description : "Authenticate with a GitHub host " ,
432
+ description : "Gh auth login [flags] " ,
338
433
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
+ } ,
339
440
{
340
441
name : [ "-h" , "--hostname" ] ,
341
442
description :
342
443
"The hostname of the GitHub instance to authenticate with" ,
343
- 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" ,
344
450
} ,
345
451
{
346
452
name : [ "-s" , "--scopes" ] ,
347
- description : "Additional authentication scopes for gh to have" ,
348
- 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" ,
349
459
} ,
350
460
{
351
461
name : [ "-w" , "--web" ] ,
@@ -354,65 +464,123 @@ const completionSpec: Fig.Spec = {
354
464
{
355
465
name : "--with-token" ,
356
466
description : "Read token from standard input" ,
357
- args : { name : "token" } ,
358
467
} ,
359
468
] ,
360
469
} ,
361
470
{
362
471
name : "logout" ,
363
- description : "Log out of a GitHub host " ,
472
+ description : "Gh auth logout [flags] " ,
364
473
options : [
365
474
{
366
475
name : [ "-h" , "--hostname" ] ,
367
- description :
368
- "The hostname of the GitHub instance to authenticate with" ,
369
- 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" } ,
370
483
} ,
371
484
] ,
372
485
} ,
373
486
{
374
487
name : "refresh" ,
375
- description : "Refresh stored authentication credentials " ,
488
+ description : "Gh auth refresh [flags] " ,
376
489
options : [
377
490
{
378
491
name : [ "-h" , "--hostname" ] ,
492
+ description : "The GitHub host to use for authentication" ,
493
+ args : { name : "string" } ,
494
+ } ,
495
+ {
496
+ name : "--insecure-storage" ,
379
497
description :
380
- "The hostname of the GitHub instance to authenticate with" ,
381
- 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" ,
382
509
} ,
383
510
{
384
511
name : [ "-s" , "--scopes" ] ,
385
512
description : "Additional authentication scopes for gh to have" ,
386
- args : { name : "scopes " } ,
513
+ args : { name : "strings " } ,
387
514
} ,
388
515
] ,
389
516
} ,
390
517
{
391
518
name : "setup-git" ,
392
- description : "Configure git to use GitHub CLI as a credential helper " ,
519
+ description : "Gh auth setup- git [flags] " ,
393
520
options : [
394
521
{
395
- name : [ "-h " , "--hostname " ] ,
522
+ name : [ "-f " , "--force " ] ,
396
523
description :
397
- "The hostname of the GitHub instance to authenticate with" ,
398
- 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" } ,
399
531
} ,
400
532
] ,
401
533
} ,
402
534
{
403
535
name : "status" ,
404
536
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" ,
405
556
options : [
406
557
{
407
558
name : [ "-h" , "--hostname" ] ,
408
559
description :
409
- "The hostname of the GitHub instance to authenticate with " ,
410
- args : { name : "hostname " } ,
560
+ "The hostname of the GitHub instance to switch account for " ,
561
+ args : { name : "string " } ,
411
562
} ,
412
563
{
413
- name : "--with-token" ,
414
- description : "Read token from standard input" ,
415
- 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" } ,
416
584
} ,
417
585
] ,
418
586
} ,
0 commit comments