Skip to content

Commit

Permalink
Use boolean function as Args.boolean seems broken
Browse files Browse the repository at this point in the history
  • Loading branch information
eablack committed Apr 4, 2024
1 parent 2e75d86 commit 96dc9a9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
12 changes: 3 additions & 9 deletions packages/cli/src/commands/pg/settings/log-lock-waits.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {flags} from '@heroku-cli/command'
import {Args} from '@oclif/core'
import heredoc from 'tsheredoc'
import {PGSettingsCommand, type Setting} from '../../../lib/pg/setter'
import {PGSettingsCommand, type Setting, boolean} from '../../../lib/pg/setter'
export default class LogLockWaits extends PGSettingsCommand {
static topic = 'pg'
static description = heredoc(`
Expand All @@ -10,20 +9,15 @@ export default class LogLockWaits extends PGSettingsCommand {
Applications and their query patterns should try to avoid changes to many different tables within the same transaction.
`)

static flags = {
app: flags.app({required: true}),
remote: flags.remote(),
}

static args = {
database: Args.string(),
value: Args.boolean(),
value: Args.string(),
}

protected settingsName = 'log_lock_waits'

protected convertValue(val: boolean): boolean {
return val
return boolean(val)
}

protected explain(setting: Setting) {
Expand Down
19 changes: 18 additions & 1 deletion packages/cli/src/lib/pg/setter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
import {Command} from '@heroku-cli/command'
import {Command, flags} from '@heroku-cli/command'
import {ux} from '@oclif/core'
import {addonResolver} from '../addons/resolve'
import host from './host'
import {essentialPlan} from './util'

export function boolean(value: any) {
switch (value) {
case 'true': case 'TRUE': case 'ON': case 'on': case true:
return true
case 'false': case 'FALSE': case 'OFF': case 'off': case null: case false:
return false
default:
throw new TypeError('Invalid value. Valid options are: a boolean value')
}
}

export interface Setting {
value: string
}
Expand All @@ -11,6 +23,11 @@ export abstract class PGSettingsCommand extends Command {
protected abstract convertValue(val: unknown): unknown
protected abstract explain(setting: Setting): string

static flags = {
app: flags.app({required: true}),
remote: flags.remote(),
}

public async run(): Promise<void> {
const {flags, args} = await this.parse()
const {app} = flags
Expand Down

0 comments on commit 96dc9a9

Please sign in to comment.