@@ -4,7 +4,10 @@ import { handleConfigAuto } from './handle-config-auto.mts'
44import constants from '../../constants.mts'
55import { commonFlags , outputFlags } from '../../flags.mts'
66import { checkCommandInput } from '../../utils/check-input.mts'
7- import { supportedConfigKeys } from '../../utils/config.mts'
7+ import {
8+ getSupportedConfigEntries ,
9+ isSupportedConfigKey ,
10+ } from '../../utils/config.mts'
811import { getOutputKind } from '../../utils/get-output-kind.mts'
912import { meowOrExit } from '../../utils/meow-with-subcommands.mts'
1013import { getFlagListOutput } from '../../utils/output-formatting.mts'
@@ -14,54 +17,48 @@ import type { CliCommandConfig } from '../../utils/meow-with-subcommands.mts'
1417
1518const { DRY_RUN_BAILING_NOW } = constants
1619
17- const config : CliCommandConfig = {
18- commandName : 'auto' ,
19- description : 'Automatically discover and set the correct value config item' ,
20- hidden : false ,
21- flags : {
22- ...commonFlags ,
23- ...outputFlags ,
24- } ,
25- help : ( command , config ) => `
20+ const description =
21+ 'Automatically discover and set the correct value config item'
22+ const hidden = false
23+
24+ export const cmdConfigAuto = {
25+ description,
26+ hidden,
27+ run,
28+ }
29+
30+ async function run (
31+ argv : string [ ] | readonly string [ ] ,
32+ importMeta : ImportMeta ,
33+ { parentName } : { parentName : string } ,
34+ ) : Promise < void > {
35+ const config : CliCommandConfig = {
36+ commandName : 'auto' ,
37+ description,
38+ hidden,
39+ flags : {
40+ ...commonFlags ,
41+ ...outputFlags ,
42+ } ,
43+ help : ( command , config ) => `
2644 Usage
2745 $ ${ command } [options] KEY
2846
2947 Options
3048 ${ getFlagListOutput ( config . flags ) }
3149
32- Attempt to automatically discover the correct value for given config KEY.
33-
34- Keys:
35-
36- ${ Array . from ( supportedConfigKeys . entries ( ) )
37- . map ( ( [ key , desc ] ) => ` - ${ key } -- ${ desc } ` )
38- . join ( '\n' ) }
50+ Attempt to automatically discover the correct value for a given config KEY.
3951
40- For certain keys it will request the value from server, for others it will
41- reset the value to the default. For some keys this has no effect.
52+ Examples
53+ $ ${ command } defaultOrg
4254
4355 Keys:
44-
45- ${ Array . from ( supportedConfigKeys . entries ( ) )
56+ ${ getSupportedConfigEntries ( )
4657 . map ( ( [ key , desc ] ) => ` - ${ key } -- ${ desc } ` )
4758 . join ( '\n' ) }
48-
49- Examples
50- $ ${ command } defaultOrg
5159 ` ,
52- }
53-
54- export const cmdConfigAuto = {
55- description : config . description ,
56- hidden : config . hidden ,
57- run,
58- }
60+ }
5961
60- async function run (
61- argv : string [ ] | readonly string [ ] ,
62- importMeta : ImportMeta ,
63- { parentName } : { parentName : string } ,
64- ) : Promise < void > {
6562 const cli = meowOrExit ( {
6663 argv,
6764 config,
@@ -78,7 +75,7 @@ async function run(
7875 const wasValidInput = checkCommandInput (
7976 outputKind ,
8077 {
81- test : supportedConfigKeys . has ( key as keyof LocalConfig ) && key !== 'test' ,
78+ test : key !== 'test' && isSupportedConfigKey ( key ) ,
8279 message : 'Config key should be the first arg' ,
8380 pass : 'ok' ,
8481 fail : key ? 'invalid config key' : 'missing' ,
0 commit comments