UNPKG

bgipfs

Version:
31 lines (30 loc) 852 B
import { confirm } from '@inquirer/prompts'; import { Command } from '@oclif/core'; import chalk from 'chalk'; export class BaseCommand extends Command { async confirm(message) { return confirm({ default: false, message: chalk.yellow(message), }); } logError(message, options) { const defaultOptions = { exit: true }; const opts = { ...defaultOptions, ...options }; if (opts.exit) { this.error(chalk.red(message), { exit: 1 }); } else { this.error(chalk.red(message), { exit: false }); } } logInfo(message) { this.log(chalk.blue(`ℹ ${message}`)); } logSuccess(message) { this.log(chalk.green(`✓ ${message}`)); } logWarning(message) { this.warn(chalk.yellow(message)); } }