Skip to content

Commit c55a5eb

Browse files
committed
Apply meowOrExit logic to remaining commands
1 parent 4e2aad0 commit c55a5eb

File tree

9 files changed

+57
-74
lines changed

9 files changed

+57
-74
lines changed

src/commands/manifest/cmd-manifest-auto.ts

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import fs from 'node:fs'
22
import path from 'node:path'
33

4-
import meow from 'meow'
5-
64
import { cmdManifestGradle } from './cmd-manifest-gradle.ts'
75
import { cmdManifestScala } from './cmd-manifest-scala.ts'
86
import { commonFlags } from '../../flags.ts'
7+
import { meowOrExit } from '../../utils/meow-with-subcommands'
98
import { getFlagListOutput } from '../../utils/output-formatting.ts'
109

1110
import type { CliCommandConfig } from '../../utils/meow-with-subcommands'
@@ -51,12 +50,11 @@ async function run(
5150
importMeta: ImportMeta,
5251
{ parentName }: { parentName: string }
5352
): Promise<void> {
54-
const cli = meow(config.help(parentName, config), {
53+
const cli = meowOrExit({
5554
argv,
56-
description: config.description,
55+
config,
5756
importMeta,
58-
flags: config.flags,
59-
allowUnknownFlags: false
57+
parentName
6058
})
6159

6260
const verbose = cli.flags['verbose'] ?? false
@@ -93,24 +91,19 @@ async function run(
9391
}
9492

9593
// Show new help screen and exit
96-
meow(
94+
console.log(
9795
`
98-
$ ${parentName} ${config.commandName}
99-
100-
Unfortunately this script did not discover a supported language in the
101-
current folder.
102-
103-
- Make sure this script would work with your target build
104-
- Make sure to run it from the correct folder
105-
- Make sure the necessary build tools are available (\`PATH\`)
106-
107-
If that doesn't work, see \`${parentName} <lang> --help\` for config details for
108-
your target language.
109-
`,
110-
{
111-
argv: [],
112-
description: config.description,
113-
importMeta
114-
}
115-
).showHelp()
96+
$ ${parentName} ${config.commandName}
97+
98+
Unfortunately this script did not discover a supported language in the
99+
current folder.
100+
101+
- Make sure this script would work with your target build
102+
- Make sure to run it from the correct folder
103+
- Make sure the necessary build tools are available (\`PATH\`)
104+
105+
If that doesn't work, see \`${parentName} <lang> --help\` for config details for
106+
your target language.
107+
`.trim()
108+
)
116109
}

src/commands/manifest/cmd-manifest-gradle.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import path from 'node:path'
22

3-
import meow from 'meow'
4-
53
import { Spinner } from '@socketsecurity/registry/lib/spinner'
64

75
import { convertGradleToMaven } from './convert_gradle_to_maven.ts'
86
import { commonFlags } from '../../flags.ts'
7+
import { meowOrExit } from '../../utils/meow-with-subcommands'
98
import { getFlagListOutput } from '../../utils/output-formatting.ts'
109

1110
import type { CliCommandConfig } from '../../utils/meow-with-subcommands'
@@ -96,13 +95,11 @@ async function run(
9695
importMeta: ImportMeta,
9796
{ parentName }: { parentName: string }
9897
): Promise<void> {
99-
// note: meow will exit if it prints the --help screen
100-
const cli = meow(config.help(parentName, config), {
101-
flags: config.flags,
102-
argv: argv.length === 0 ? ['--help'] : argv,
103-
description: config.description,
104-
allowUnknownFlags: false,
105-
importMeta
98+
const cli = meowOrExit({
99+
argv,
100+
config,
101+
importMeta,
102+
parentName
106103
})
107104

108105
const verbose = Boolean(cli.flags['verbose'])

src/commands/manifest/cmd-manifest-kotlin.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import path from 'node:path'
22

3-
import meow from 'meow'
4-
53
import { Spinner } from '@socketsecurity/registry/lib/spinner'
64

75
import { convertGradleToMaven } from './convert_gradle_to_maven.ts'
86
import { commonFlags } from '../../flags.ts'
7+
import { meowOrExit } from '../../utils/meow-with-subcommands'
98
import { getFlagListOutput } from '../../utils/output-formatting.ts'
109

1110
import type { CliCommandConfig } from '../../utils/meow-with-subcommands'
@@ -101,13 +100,11 @@ async function run(
101100
importMeta: ImportMeta,
102101
{ parentName }: { parentName: string }
103102
): Promise<void> {
104-
// note: meow will exit if it prints the --help screen
105-
const cli = meow(config.help(parentName, config), {
106-
flags: config.flags,
107-
argv: argv.length === 0 ? ['--help'] : argv,
108-
description: config.description,
109-
allowUnknownFlags: false,
110-
importMeta
103+
const cli = meowOrExit({
104+
argv,
105+
config,
106+
importMeta,
107+
parentName
111108
})
112109

113110
const verbose = Boolean(cli.flags['verbose'])

src/commands/manifest/cmd-manifest-scala.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import meow from 'meow'
2-
31
import { Spinner } from '@socketsecurity/registry/lib/spinner'
42

53
import { convertSbtToMaven } from './convert_sbt_to_maven.ts'
64
import { commonFlags } from '../../flags.ts'
5+
import { meowOrExit } from '../../utils/meow-with-subcommands'
76
import { getFlagListOutput } from '../../utils/output-formatting.ts'
87

98
import type { CliCommandConfig } from '../../utils/meow-with-subcommands'
@@ -91,14 +90,11 @@ async function run(
9190
importMeta: ImportMeta,
9291
{ parentName }: { parentName: string }
9392
): Promise<void> {
94-
// console.log('scala', argv, parentName)
95-
// note: meow will exit if it prints the --help screen
96-
const cli = meow(config.help(parentName, config), {
97-
flags: config.flags,
98-
argv: argv.length === 0 ? ['--help'] : argv,
99-
description: config.description,
100-
allowUnknownFlags: false,
101-
importMeta
93+
const cli = meowOrExit({
94+
argv,
95+
config,
96+
importMeta,
97+
parentName
10298
})
10399

104100
const verbose = Boolean(cli.flags['verbose'])

src/commands/oops/cmd-oops.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import meowOrExit from 'meow'
1+
import { meowOrExit } from '../../utils/meow-with-subcommands.ts'
22

3-
import { CliCommandConfig } from '../../utils/meow-with-subcommands.ts'
3+
import type { CliCommandConfig } from '../../utils/meow-with-subcommands.ts'
44

55
const config: CliCommandConfig = {
66
commandName: 'oops',
@@ -26,11 +26,11 @@ async function run(
2626
importMeta: ImportMeta,
2727
{ parentName }: { parentName: string }
2828
): Promise<void> {
29-
meowOrExit(config.help(parentName, config), {
29+
meowOrExit({
3030
argv,
31-
description: config.description,
31+
config,
3232
importMeta,
33-
flags: config.flags
33+
parentName
3434
})
3535

3636
throw new Error('This error was intentionally left blank')

src/commands/scan/cmd-scan-delete.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import meow from 'meow'
21
import colors from 'yoctocolors-cjs'
32

43
import { deleteOrgFullScan } from './delete-full-scan.ts'
54
import { commonFlags, outputFlags } from '../../flags'
65
import { AuthError } from '../../utils/errors'
6+
import { meowOrExit } from '../../utils/meow-with-subcommands'
77
import { getFlagListOutput } from '../../utils/output-formatting'
88
import { getDefaultToken } from '../../utils/sdk'
99

@@ -40,11 +40,11 @@ async function run(
4040
importMeta: ImportMeta,
4141
{ parentName }: { parentName: string }
4242
): Promise<void> {
43-
const cli = meow(config.help(parentName, config), {
43+
const cli = meowOrExit({
4444
argv,
45-
description: config.description,
45+
config,
4646
importMeta,
47-
flags: config.flags
47+
parentName
4848
})
4949

5050
const [orgSlug = '', fullScanId = ''] = cli.input

src/commands/scan/cmd-scan-list.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import meow from 'meow'
21
import colors from 'yoctocolors-cjs'
32

43
import { listFullScans } from './list-full-scans.ts'
54
import { commonFlags, outputFlags } from '../../flags'
65
import { AuthError } from '../../utils/errors'
6+
import { meowOrExit } from '../../utils/meow-with-subcommands'
77
import { getFlagListOutput } from '../../utils/output-formatting'
88
import { getDefaultToken } from '../../utils/sdk'
99

@@ -80,11 +80,11 @@ async function run(
8080
importMeta: ImportMeta,
8181
{ parentName }: { parentName: string }
8282
) {
83-
const cli = meow(config.help(parentName, config), {
83+
const cli = meowOrExit({
8484
argv,
85-
description: config.description,
85+
config,
8686
importMeta,
87-
flags: config.flags
87+
parentName
8888
})
8989

9090
const orgSlug = cli.input[0]

src/commands/scan/cmd-scan-metadata.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import meow from 'meow'
21
import colors from 'yoctocolors-cjs'
32

43
import { getOrgScanMetadata } from './get-full-scan-metadata.ts'
54
import { commonFlags, outputFlags } from '../../flags'
65
import { AuthError } from '../../utils/errors'
6+
import { meowOrExit } from '../../utils/meow-with-subcommands'
77
import { getFlagListOutput } from '../../utils/output-formatting'
88
import { getDefaultToken } from '../../utils/sdk'
99

@@ -43,11 +43,11 @@ async function run(
4343
importMeta: ImportMeta,
4444
{ parentName }: { parentName: string }
4545
): Promise<void> {
46-
const cli = meow(config.help(parentName, config), {
46+
const cli = meowOrExit({
4747
argv,
48-
description: config.description,
48+
config,
4949
importMeta,
50-
flags: config.flags
50+
parentName
5151
})
5252

5353
const [orgSlug = '', fullScanId = ''] = cli.input

src/commands/scan/cmd-scan-stream.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import meow from 'meow'
21
import colors from 'yoctocolors-cjs'
32

43
import { getFullScan } from './get-full-scan.ts'
54
import { commonFlags, outputFlags } from '../../flags'
65
import { AuthError } from '../../utils/errors'
6+
import { meowOrExit } from '../../utils/meow-with-subcommands'
77
import { getFlagListOutput } from '../../utils/output-formatting'
88
import { getDefaultToken } from '../../utils/sdk'
99

@@ -45,11 +45,11 @@ async function run(
4545
importMeta: ImportMeta,
4646
{ parentName }: { parentName: string }
4747
): Promise<void> {
48-
const cli = meow(config.help(parentName, config), {
48+
const cli = meowOrExit({
4949
argv,
50-
description: config.description,
50+
config,
5151
importMeta,
52-
flags: config.flags
52+
parentName
5353
})
5454

5555
const [orgSlug = '', fullScanId = '', file = '-'] = cli.input

0 commit comments

Comments
 (0)