Skip to content

Flip from negative to positive checkCommandInput #497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2025
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/analytics/cmd-analytics.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { commonFlags, outputFlags } from '../../flags.mts'
import { isTestingV1 } from '../../utils/config.mts'
import { getOutputKind } from '../../utils/get-output-kind.mts'
import { checkCommandInput } from '../../utils/handle-bad-input.mts'
import { checkCommandInput } from '../../utils/check-input.mts'

Check warning on line 8 in src/commands/analytics/cmd-analytics.mts

View workflow job for this annotation

GitHub Actions / Linting / Test (20, ubuntu-latest)

`../../utils/check-input.mts` import should occur before import of `../../utils/config.mts`
import { meowOrExit } from '../../utils/meow-with-subcommands.mts'
import { getFlagListOutput } from '../../utils/output-formatting.mts'
import { getDefaultToken } from '../../utils/sdk.mts'
Expand Down Expand Up @@ -140,7 +140,7 @@

const apiToken = getDefaultToken()

const wasBadInput = checkCommandInput(
const wasValidInput = checkCommandInput(
outputKind,
{
// In v1 this can't go wrong anymore since the unknown value goes to time
Expand Down Expand Up @@ -206,7 +206,7 @@
fail: 'missing API token'
}
)
if (wasBadInput) {
if (!wasValidInput) {
return
}

Expand Down
6 changes: 3 additions & 3 deletions src/commands/audit-log/cmd-audit-log.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { isTestingV1 } from '../../utils/config.mts'
import { determineOrgSlug } from '../../utils/determine-org-slug.mts'
import { getOutputKind } from '../../utils/get-output-kind.mts'
import { checkCommandInput } from '../../utils/handle-bad-input.mts'
import { checkCommandInput } from '../../utils/check-input.mts'

Check warning on line 9 in src/commands/audit-log/cmd-audit-log.mts

View workflow job for this annotation

GitHub Actions / Linting / Test (20, ubuntu-latest)

`../../utils/check-input.mts` import should occur before import of `../../utils/config.mts`
import { meowOrExit } from '../../utils/meow-with-subcommands.mts'
import { getFlagListOutput } from '../../utils/output-formatting.mts'
import { getDefaultToken } from '../../utils/sdk.mts'
Expand Down Expand Up @@ -111,7 +111,7 @@

const apiToken = getDefaultToken()

const wasBadInput = checkCommandInput(
const wasValidInput = checkCommandInput(
outputKind,
{
nook: true,
Expand Down Expand Up @@ -139,7 +139,7 @@
fail: 'bad'
}
)
if (wasBadInput) {
if (!wasValidInput) {
return
}

Expand Down
6 changes: 3 additions & 3 deletions src/commands/config/cmd-config-auto.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { commonFlags, outputFlags } from '../../flags.mts'
import { supportedConfigKeys } from '../../utils/config.mts'
import { getOutputKind } from '../../utils/get-output-kind.mts'
import { checkCommandInput } from '../../utils/handle-bad-input.mts'
import { checkCommandInput } from '../../utils/check-input.mts'

Check warning on line 8 in src/commands/config/cmd-config-auto.mts

View workflow job for this annotation

GitHub Actions / Linting / Test (20, ubuntu-latest)

`../../utils/check-input.mts` import should occur before import of `../../utils/config.mts`
import { meowOrExit } from '../../utils/meow-with-subcommands.mts'
import { getFlagListOutput } from '../../utils/output-formatting.mts'

Expand Down Expand Up @@ -68,7 +68,7 @@

const [key = ''] = cli.input

const wasBadInput = checkCommandInput(
const wasValidInput = checkCommandInput(
outputKind,
{
test: supportedConfigKeys.has(key as keyof LocalConfig) && key !== 'test',
Expand All @@ -85,7 +85,7 @@
fail: 'bad'
}
)
if (wasBadInput) {
if (!wasValidInput) {
return
}

Expand Down
6 changes: 3 additions & 3 deletions src/commands/config/cmd-config-get.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { commonFlags, outputFlags } from '../../flags.mts'
import { supportedConfigKeys } from '../../utils/config.mts'
import { getOutputKind } from '../../utils/get-output-kind.mts'
import { checkCommandInput } from '../../utils/handle-bad-input.mts'
import { checkCommandInput } from '../../utils/check-input.mts'

Check warning on line 8 in src/commands/config/cmd-config-get.mts

View workflow job for this annotation

GitHub Actions / Linting / Test (20, ubuntu-latest)

`../../utils/check-input.mts` import should occur before import of `../../utils/config.mts`
import { meowOrExit } from '../../utils/meow-with-subcommands.mts'
import { getFlagListOutput } from '../../utils/output-formatting.mts'

Expand Down Expand Up @@ -63,7 +63,7 @@

const [key = ''] = cli.input

const wasBadInput = checkCommandInput(
const wasValidInput = checkCommandInput(
outputKind,
{
test: supportedConfigKeys.has(key as keyof LocalConfig) || key === 'test',
Expand All @@ -80,7 +80,7 @@
fail: 'bad'
}
)
if (wasBadInput) {
if (!wasValidInput) {
return
}

Expand Down
6 changes: 3 additions & 3 deletions src/commands/config/cmd-config-list.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { commonFlags, outputFlags } from '../../flags.mts'
import { supportedConfigKeys } from '../../utils/config.mts'
import { getOutputKind } from '../../utils/get-output-kind.mts'
import { checkCommandInput } from '../../utils/handle-bad-input.mts'
import { checkCommandInput } from '../../utils/check-input.mts'

Check warning on line 8 in src/commands/config/cmd-config-list.mts

View workflow job for this annotation

GitHub Actions / Linting / Test (20, ubuntu-latest)

`../../utils/check-input.mts` import should occur before import of `../../utils/config.mts`
import { meowOrExit } from '../../utils/meow-with-subcommands.mts'
import { getFlagListOutput } from '../../utils/output-formatting.mts'

Expand Down Expand Up @@ -65,15 +65,15 @@
const { full, json, markdown } = cli.flags
const outputKind = getOutputKind(json, markdown)

const wasBadInput = checkCommandInput(outputKind, {
const wasValidInput = checkCommandInput(outputKind, {
nook: true,
test: !json || !markdown,
message:
'The `--json` and `--markdown` flags can not be used at the same time',
pass: 'ok',
fail: 'bad'
})
if (wasBadInput) {
if (!wasValidInput) {
return
}

Expand Down
6 changes: 3 additions & 3 deletions src/commands/config/cmd-config-set.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { commonFlags, outputFlags } from '../../flags.mts'
import { supportedConfigKeys } from '../../utils/config.mts'
import { getOutputKind } from '../../utils/get-output-kind.mts'
import { checkCommandInput } from '../../utils/handle-bad-input.mts'
import { checkCommandInput } from '../../utils/check-input.mts'

Check warning on line 8 in src/commands/config/cmd-config-set.mts

View workflow job for this annotation

GitHub Actions / Linting / Test (20, ubuntu-latest)

`../../utils/check-input.mts` import should occur before import of `../../utils/config.mts`
import { meowOrExit } from '../../utils/meow-with-subcommands.mts'
import { getFlagListOutput } from '../../utils/output-formatting.mts'

Expand Down Expand Up @@ -69,7 +69,7 @@
const [key = '', ...rest] = cli.input
const value = rest.join(' ')

const wasBadInput = checkCommandInput(
const wasValidInput = checkCommandInput(
outputKind,
{
test: key === 'test' || supportedConfigKeys.has(key as keyof LocalConfig),
Expand All @@ -93,7 +93,7 @@
fail: 'bad'
}
)
if (wasBadInput) {
if (!wasValidInput) {
return
}

Expand Down
6 changes: 3 additions & 3 deletions src/commands/config/cmd-config-unset.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { commonFlags, outputFlags } from '../../flags.mts'
import { supportedConfigKeys } from '../../utils/config.mts'
import { getOutputKind } from '../../utils/get-output-kind.mts'
import { checkCommandInput } from '../../utils/handle-bad-input.mts'
import { checkCommandInput } from '../../utils/check-input.mts'

Check warning on line 8 in src/commands/config/cmd-config-unset.mts

View workflow job for this annotation

GitHub Actions / Linting / Test (20, ubuntu-latest)

`../../utils/check-input.mts` import should occur before import of `../../utils/config.mts`
import { meowOrExit } from '../../utils/meow-with-subcommands.mts'
import { getFlagListOutput } from '../../utils/output-formatting.mts'

Expand Down Expand Up @@ -63,7 +63,7 @@

const [key = ''] = cli.input

const wasBadInput = checkCommandInput(
const wasValidInput = checkCommandInput(
outputKind,
{
test: key === 'test' || supportedConfigKeys.has(key as keyof LocalConfig),
Expand All @@ -80,7 +80,7 @@
fail: 'bad'
}
)
if (wasBadInput) {
if (!wasValidInput) {
return
}

Expand Down
6 changes: 3 additions & 3 deletions src/commands/dependencies/cmd-dependencies.mts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import constants from '../../constants.mts'
import { commonFlags, outputFlags } from '../../flags.mts'
import { getOutputKind } from '../../utils/get-output-kind.mts'
import { checkCommandInput } from '../../utils/handle-bad-input.mts'
import { checkCommandInput } from '../../utils/check-input.mts'

Check warning on line 7 in src/commands/dependencies/cmd-dependencies.mts

View workflow job for this annotation

GitHub Actions / Linting / Test (20, ubuntu-latest)

`../../utils/check-input.mts` import should occur before import of `../../utils/get-output-kind.mts`
import { meowOrExit } from '../../utils/meow-with-subcommands.mts'
import { getFlagListOutput } from '../../utils/output-formatting.mts'
import { getDefaultToken } from '../../utils/sdk.mts'
Expand Down Expand Up @@ -73,7 +73,7 @@

const apiToken = getDefaultToken()

const wasBadInput = checkCommandInput(
const wasValidInput = checkCommandInput(
outputKind,
{
nook: true,
Expand All @@ -92,7 +92,7 @@
fail: 'missing API token'
}
)
if (wasBadInput) {
if (!wasValidInput) {
return
}

Expand Down
6 changes: 3 additions & 3 deletions src/commands/diff-scan/cmd-diff-scan-get.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { commonFlags } from '../../flags.mts'
import { getConfigValueOrUndef, isTestingV1 } from '../../utils/config.mts'
import { getOutputKind } from '../../utils/get-output-kind.mts'
import { checkCommandInput } from '../../utils/handle-bad-input.mts'
import { checkCommandInput } from '../../utils/check-input.mts'

Check warning on line 8 in src/commands/diff-scan/cmd-diff-scan-get.mts

View workflow job for this annotation

GitHub Actions / Linting / Test (20, ubuntu-latest)

`../../utils/check-input.mts` import should occur before import of `../../utils/config.mts`
import { meowOrExit } from '../../utils/meow-with-subcommands.mts'
import { getFlagListOutput } from '../../utils/output-formatting.mts'
import { getDefaultToken } from '../../utils/sdk.mts'
Expand Down Expand Up @@ -105,7 +105,7 @@

const apiToken = getDefaultToken()

const wasBadInput = checkCommandInput(
const wasValidInput = checkCommandInput(
outputKind,
{
test: !!(before && after),
Expand Down Expand Up @@ -143,7 +143,7 @@
fail: 'missing API token'
}
)
if (wasBadInput) {
if (!wasValidInput) {
return
}

Expand Down
6 changes: 3 additions & 3 deletions src/commands/fix/cmd-fix.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { runFix } from './run-fix.mts'
import { commonFlags } from '../../flags.mts'
import { getOutputKind } from '../../utils/get-output-kind.mts'
import { checkCommandInput } from '../../utils/handle-bad-input.mts'
import { checkCommandInput } from '../../utils/check-input.mts'

Check warning on line 8 in src/commands/fix/cmd-fix.mts

View workflow job for this annotation

GitHub Actions / Linting / Test (20, ubuntu-latest)

`../../utils/check-input.mts` import should occur before import of `../../utils/get-output-kind.mts`
import { meowOrExit } from '../../utils/meow-with-subcommands.mts'
import { getFlagListOutput } from '../../utils/output-formatting.mts'
import { RangeStyles } from '../../utils/semver.mts'
Expand Down Expand Up @@ -99,13 +99,13 @@
const { json, markdown } = cli.flags
const outputKind = getOutputKind(json, markdown) // TODO: impl json/md further

const wasBadInput = checkCommandInput(outputKind, {
const wasValidInput = checkCommandInput(outputKind, {
test: RangeStyles.includes(cli.flags['rangeStyle'] as string),
message: `Expecting range style of ${joinOr(RangeStyles)}`,
pass: 'ok',
fail: 'missing'
})
if (wasBadInput) {
if (!wasValidInput) {
return
}

Expand Down
6 changes: 3 additions & 3 deletions src/commands/info/cmd-info.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import constants from '../../constants.mts'
import { commonFlags, outputFlags, validationFlags } from '../../flags.mts'
import { isTestingV1 } from '../../utils/config.mts'
import { getOutputKind } from '../../utils/get-output-kind.mts'
import { checkCommandInput } from '../../utils/handle-bad-input.mts'
import { checkCommandInput } from '../../utils/check-input.mts'
import { meowOrExit } from '../../utils/meow-with-subcommands.mts'
import { getFlagListOutput } from '../../utils/output-formatting.mts'

Expand Down Expand Up @@ -63,7 +63,7 @@ async function run(

const [rawPkgName = ''] = cli.input

const wasBadInput = checkCommandInput(
const wasValidInput = checkCommandInput(
outputKind,
{
test: !!rawPkgName,
Expand All @@ -87,7 +87,7 @@ async function run(
fail: 'bad'
}
)
if (wasBadInput) {
if (!wasValidInput) {
return
}

Expand Down
6 changes: 3 additions & 3 deletions src/commands/manifest/cmd-manifest-conda.mts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { handleManifestConda } from './handle-manifest-conda.mts'
import constants from '../../constants.mts'
import { commonFlags, outputFlags } from '../../flags.mts'
import { getOutputKind } from '../../utils/get-output-kind.mts'
import { checkCommandInput } from '../../utils/handle-bad-input.mts'
import { checkCommandInput } from '../../utils/check-input.mts'
import { meowOrExit } from '../../utils/meow-with-subcommands.mts'
import { getFlagListOutput } from '../../utils/output-formatting.mts'

Expand Down Expand Up @@ -94,7 +94,7 @@ async function run(
logger.groupEnd()
}

const wasBadInput = checkCommandInput(
const wasValidInput = checkCommandInput(
outputKind,
{
test: !!target,
Expand All @@ -118,7 +118,7 @@ async function run(
fail: 'bad'
}
)
if (wasBadInput) {
if (!wasValidInput) {
return
}

Expand Down
6 changes: 3 additions & 3 deletions src/commands/manifest/cmd-manifest-gradle.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { convertGradleToMaven } from './convert_gradle_to_maven.mts'
import constants from '../../constants.mts'
import { commonFlags } from '../../flags.mts'
import { getOutputKind } from '../../utils/get-output-kind.mts'
import { checkCommandInput } from '../../utils/handle-bad-input.mts'
import { checkCommandInput } from '../../utils/check-input.mts'
import { meowOrExit } from '../../utils/meow-with-subcommands.mts'
import { getFlagListOutput } from '../../utils/output-formatting.mts'

Expand Down Expand Up @@ -115,7 +115,7 @@ async function run(
// try, store contents in a file in some folder, target that folder... what
// would the file name be?

const wasBadInput = checkCommandInput(
const wasValidInput = checkCommandInput(
outputKind,
{
test: !!target && target !== '-',
Expand All @@ -131,7 +131,7 @@ async function run(
fail: 'received ' + cli.input.length
}
)
if (wasBadInput) {
if (!wasValidInput) {
return
}

Expand Down
6 changes: 3 additions & 3 deletions src/commands/manifest/cmd-manifest-kotlin.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { convertGradleToMaven } from './convert_gradle_to_maven.mts'
import constants from '../../constants.mts'
import { commonFlags } from '../../flags.mts'
import { getOutputKind } from '../../utils/get-output-kind.mts'
import { checkCommandInput } from '../../utils/handle-bad-input.mts'
import { checkCommandInput } from '../../utils/check-input.mts'
import { meowOrExit } from '../../utils/meow-with-subcommands.mts'
import { getFlagListOutput } from '../../utils/output-formatting.mts'

Expand Down Expand Up @@ -120,7 +120,7 @@ async function run(
// try, store contents in a file in some folder, target that folder... what
// would the file name be?

const wasBadInput = checkCommandInput(
const wasValidInput = checkCommandInput(
outputKind,
{
test: !!target && target !== '-',
Expand All @@ -136,7 +136,7 @@ async function run(
fail: 'received ' + cli.input.length
}
)
if (wasBadInput) {
if (!wasValidInput) {
return
}

Expand Down
Loading
Loading