import { Command } from '@oclif/core';
import { CliExit } from '../lib/cli-exit.js';
import { resolveLang } from './i18n.js';
// Shared oclif boundary: command bodies may throw CliExit, and process.argv is
// stable for one CLI invocation, so language resolution is cached per command.
export class BaseCommand extends Command {
    #lang;
    get lang() {
        this.#lang ??= resolveLang(process.argv);
        return this.#lang;
    }
    async runWithCliExit(fn) {
        try {
            await fn();
        }
        catch (err) {
            if (err instanceof CliExit) {
                if (err.code === 0)
                    return;
                this.exit(err.code);
                return;
            }
            throw err;
        }
    }
}
//# sourceMappingURL=base-command.js.map