import { Args } from '@oclif/core';
import tsheredoc from 'tsheredoc';
import { PGSettingsCommand, numericConverter } from '../../../../lib/pg/setter.js';
import { nls } from '../../../../nls.js';
const heredoc = tsheredoc.default;
export default class LogMinDuration extends PGSettingsCommand {
    static topic = 'pg';
    static description = heredoc(`
    Sets the minimum execution time in milliseconds for a statement's plan to be logged.
    Setting this value to 0 will log all queries. Setting this value to -1 will disable logging entirely.
  `);
    static args = {
        database: Args.string({ description: `${nls('pg:database:arg:description')} ${nls('pg:database:arg:description:default:suffix')}` }),
        value: Args.string({ description: 'minimum duration in milliseconds for queries before logging execution plans. A value of -1 disables it. A value of 0 logs all query execution plans.' }),
    };
    settingKey = 'auto_explain.log_min_duration';
    convertValue(val) {
        return numericConverter(val);
    }
    explain(setting) {
        if (setting.value === -1) {
            return 'Execution plan logging has been disabled.';
        }
        if (setting.value === 0) {
            return 'All queries will have their execution plans logged.';
        }
        return `All execution plans will be logged for queries taking up to ${setting.value} milliseconds or more.`;
    }
}
