Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/commands/action/cmd-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ const config: CliCommandConfig = {
description: 'After marker'
}
},
help: (parentName, { commandName, flags }) => `
help: (command, config) => `
Usage
$ ${parentName} ${commandName} [options]
$ ${command} [options]

Options
${getFlagListOutput(flags, 6)}
${getFlagListOutput(config.flags, 6)}
`
}

Expand Down
12 changes: 6 additions & 6 deletions src/commands/analytics/cmd-analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ const config: CliCommandConfig = {
description: 'Path to a local file to save the output'
}
},
help: (parentName, { commandName, flags }) => `
help: (command, config) => `
Usage
$ ${parentName} ${commandName} --scope=<scope> --time=<time filter>
$ ${command} --scope=<scope> --time=<time filter>

Default parameters are set to show the organization-level analytics over the
last 7 days.

Options
${getFlagListOutput(flags, 6)}
${getFlagListOutput(config.flags, 6)}

Examples
$ ${parentName} ${commandName} --scope=org --time=7
$ ${parentName} ${commandName} --scope=org --time=30
$ ${parentName} ${commandName} --scope=repo --repo=test-repo --time=30
$ ${command} --scope=org --time=7
$ ${command} --scope=org --time=30
$ ${command} --scope=repo --repo=test-repo --time=30
`
}

Expand Down
43 changes: 18 additions & 25 deletions src/commands/manifest/cmd-manifest-auto.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import fs from 'node:fs'
import path from 'node:path'

import meow from 'meow'

import { cmdManifestGradle } from './cmd-manifest-gradle.ts'
import { cmdManifestScala } from './cmd-manifest-scala.ts'
import { commonFlags } from '../../flags.ts'
import { meowOrExit } from '../../utils/meow-with-subcommands'
import { getFlagListOutput } from '../../utils/output-formatting.ts'

import type { CliCommandConfig } from '../../utils/meow-with-subcommands'
Expand Down Expand Up @@ -51,12 +50,11 @@ async function run(
importMeta: ImportMeta,
{ parentName }: { parentName: string }
): Promise<void> {
const cli = meow(config.help(parentName, config), {
const cli = meowOrExit({
argv,
description: config.description,
config,
importMeta,
flags: config.flags,
allowUnknownFlags: false
parentName
})

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

// Show new help screen and exit
meow(
console.log(
`
$ ${parentName} ${config.commandName}

Unfortunately this script did not discover a supported language in the
current folder.

- Make sure this script would work with your target build
- Make sure to run it from the correct folder
- Make sure the necessary build tools are available (\`PATH\`)

If that doesn't work, see \`${parentName} <lang> --help\` for config details for
your target language.
`,
{
argv: [],
description: config.description,
importMeta
}
).showHelp()
$ ${parentName} ${config.commandName}

Unfortunately this script did not discover a supported language in the
current folder.

- Make sure this script would work with your target build
- Make sure to run it from the correct folder
- Make sure the necessary build tools are available (\`PATH\`)

If that doesn't work, see \`${parentName} <lang> --help\` for config details for
your target language.
`.trim()
)
}
15 changes: 6 additions & 9 deletions src/commands/manifest/cmd-manifest-gradle.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import path from 'node:path'

import meow from 'meow'

import { Spinner } from '@socketsecurity/registry/lib/spinner'

import { convertGradleToMaven } from './convert_gradle_to_maven.ts'
import { commonFlags } from '../../flags.ts'
import { meowOrExit } from '../../utils/meow-with-subcommands'
import { getFlagListOutput } from '../../utils/output-formatting.ts'

import type { CliCommandConfig } from '../../utils/meow-with-subcommands'
Expand Down Expand Up @@ -96,13 +95,11 @@ async function run(
importMeta: ImportMeta,
{ parentName }: { parentName: string }
): Promise<void> {
// note: meow will exit if it prints the --help screen
const cli = meow(config.help(parentName, config), {
flags: config.flags,
argv: argv.length === 0 ? ['--help'] : argv,
description: config.description,
allowUnknownFlags: false,
importMeta
const cli = meowOrExit({
argv,
config,
importMeta,
parentName
})

const verbose = Boolean(cli.flags['verbose'])
Expand Down
15 changes: 6 additions & 9 deletions src/commands/manifest/cmd-manifest-kotlin.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import path from 'node:path'

import meow from 'meow'

import { Spinner } from '@socketsecurity/registry/lib/spinner'

import { convertGradleToMaven } from './convert_gradle_to_maven.ts'
import { commonFlags } from '../../flags.ts'
import { meowOrExit } from '../../utils/meow-with-subcommands'
import { getFlagListOutput } from '../../utils/output-formatting.ts'

import type { CliCommandConfig } from '../../utils/meow-with-subcommands'
Expand Down Expand Up @@ -101,13 +100,11 @@ async function run(
importMeta: ImportMeta,
{ parentName }: { parentName: string }
): Promise<void> {
// note: meow will exit if it prints the --help screen
const cli = meow(config.help(parentName, config), {
flags: config.flags,
argv: argv.length === 0 ? ['--help'] : argv,
description: config.description,
allowUnknownFlags: false,
importMeta
const cli = meowOrExit({
argv,
config,
importMeta,
parentName
})

const verbose = Boolean(cli.flags['verbose'])
Expand Down
16 changes: 6 additions & 10 deletions src/commands/manifest/cmd-manifest-scala.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import meow from 'meow'

import { Spinner } from '@socketsecurity/registry/lib/spinner'

import { convertSbtToMaven } from './convert_sbt_to_maven.ts'
import { commonFlags } from '../../flags.ts'
import { meowOrExit } from '../../utils/meow-with-subcommands'
import { getFlagListOutput } from '../../utils/output-formatting.ts'

import type { CliCommandConfig } from '../../utils/meow-with-subcommands'
Expand Down Expand Up @@ -91,14 +90,11 @@ async function run(
importMeta: ImportMeta,
{ parentName }: { parentName: string }
): Promise<void> {
// console.log('scala', argv, parentName)
// note: meow will exit if it prints the --help screen
const cli = meow(config.help(parentName, config), {
flags: config.flags,
argv: argv.length === 0 ? ['--help'] : argv,
description: config.description,
allowUnknownFlags: false,
importMeta
const cli = meowOrExit({
argv,
config,
importMeta,
parentName
})

const verbose = Boolean(cli.flags['verbose'])
Expand Down
14 changes: 7 additions & 7 deletions src/commands/oops/cmd-oops.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import meowOrExit from 'meow'
import { meowOrExit } from '../../utils/meow-with-subcommands.ts'

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

const config: CliCommandConfig = {
commandName: 'oops',
description: 'Trigger an intentional error (for development)',
hidden: true,
flags: {},
help: (parentName, config) => `
help: (command, _config) => `
Usage
$ ${parentName} ${config.commandName}
$ ${command}

Don't run me.
`
Expand All @@ -26,11 +26,11 @@ async function run(
importMeta: ImportMeta,
{ parentName }: { parentName: string }
): Promise<void> {
meowOrExit(config.help(parentName, config), {
meowOrExit({
argv,
description: config.description,
config,
importMeta,
flags: config.flags
parentName
})

throw new Error('This error was intentionally left blank')
Expand Down
8 changes: 4 additions & 4 deletions src/commands/scan/cmd-scan-delete.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import meow from 'meow'
import colors from 'yoctocolors-cjs'

import { deleteOrgFullScan } from './delete-full-scan.ts'
import { commonFlags, outputFlags } from '../../flags'
import { AuthError } from '../../utils/errors'
import { meowOrExit } from '../../utils/meow-with-subcommands'
import { getFlagListOutput } from '../../utils/output-formatting'
import { getDefaultToken } from '../../utils/sdk'

Expand Down Expand Up @@ -40,11 +40,11 @@ async function run(
importMeta: ImportMeta,
{ parentName }: { parentName: string }
): Promise<void> {
const cli = meow(config.help(parentName, config), {
const cli = meowOrExit({
argv,
description: config.description,
config,
importMeta,
flags: config.flags
parentName
})

const [orgSlug = '', fullScanId = ''] = cli.input
Expand Down
8 changes: 4 additions & 4 deletions src/commands/scan/cmd-scan-list.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import meow from 'meow'
import colors from 'yoctocolors-cjs'

import { listFullScans } from './list-full-scans.ts'
import { commonFlags, outputFlags } from '../../flags'
import { AuthError } from '../../utils/errors'
import { meowOrExit } from '../../utils/meow-with-subcommands'
import { getFlagListOutput } from '../../utils/output-formatting'
import { getDefaultToken } from '../../utils/sdk'

Expand Down Expand Up @@ -80,11 +80,11 @@ async function run(
importMeta: ImportMeta,
{ parentName }: { parentName: string }
) {
const cli = meow(config.help(parentName, config), {
const cli = meowOrExit({
argv,
description: config.description,
config,
importMeta,
flags: config.flags
parentName
})

const orgSlug = cli.input[0]
Expand Down
8 changes: 4 additions & 4 deletions src/commands/scan/cmd-scan-metadata.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import meow from 'meow'
import colors from 'yoctocolors-cjs'

import { getOrgScanMetadata } from './get-full-scan-metadata.ts'
import { commonFlags, outputFlags } from '../../flags'
import { AuthError } from '../../utils/errors'
import { meowOrExit } from '../../utils/meow-with-subcommands'
import { getFlagListOutput } from '../../utils/output-formatting'
import { getDefaultToken } from '../../utils/sdk'

Expand Down Expand Up @@ -43,11 +43,11 @@ async function run(
importMeta: ImportMeta,
{ parentName }: { parentName: string }
): Promise<void> {
const cli = meow(config.help(parentName, config), {
const cli = meowOrExit({
argv,
description: config.description,
config,
importMeta,
flags: config.flags
parentName
})

const [orgSlug = '', fullScanId = ''] = cli.input
Expand Down
8 changes: 4 additions & 4 deletions src/commands/scan/cmd-scan-stream.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import meow from 'meow'
import colors from 'yoctocolors-cjs'

import { getFullScan } from './get-full-scan.ts'
import { commonFlags, outputFlags } from '../../flags'
import { AuthError } from '../../utils/errors'
import { meowOrExit } from '../../utils/meow-with-subcommands'
import { getFlagListOutput } from '../../utils/output-formatting'
import { getDefaultToken } from '../../utils/sdk'

Expand Down Expand Up @@ -45,11 +45,11 @@ async function run(
importMeta: ImportMeta,
{ parentName }: { parentName: string }
): Promise<void> {
const cli = meow(config.help(parentName, config), {
const cli = meowOrExit({
argv,
description: config.description,
config,
importMeta,
flags: config.flags
parentName
})

const [orgSlug = '', fullScanId = '', file = '-'] = cli.input
Expand Down
Loading