import chalk from 'chalk'
import gradient from 'gradient-string'
import _ from 'lodash'

export interface OpenDBiOptions {
  readonly keystore: boolean
}

export function hasCliOptions(opts: OpenDBiOptions): opts is OpenDBiOptions {
  return _.compact(_.values(opts)).length > 0
}

export function getIntro(): string {
  const columns = process.stdout.columns
  // TSES-lint:  error throw Unnecessary escape character: \ : Comment
  const ascii = `
     ___                   ____  ____
    / _ \ _ __   ___ _ __ |  _ \| __ )
   | | | | '_ \ / _ \ '_ \| | | |  _ \
   | |_| | |_) |  __/ | | | |_| | |_) |
    \___/| .__/ \___|_| |_|____/|____/
         |_|
    `
  const asciiSmaller = `
     ___                   ____  ____
    / _ \ _ __   ___ _ __ |  _ \| __ )
   | | | | '_ \ / _ \ '_ \| | | |  _ \
   | |_| | |_) |  __/ | | | |_| | |_) |
    \___/| .__/ \___|_| |_|____/|____/
         |_|
  `
  return columns && columns >= 85
    ? chalk.bold(gradient.mind(ascii))
    : columns && columns >= 74
    ? chalk.bold(gradient.mind(asciiSmaller))
    : `\n${chalk.cyan.bold.underline('OpenDB client cli - openDBi')}\n`
}

export const underlineChalk = (text) => `${chalk.cyan.bold.underline(text)}\n`
