An interactive command-line interface (CLI) tool to help you install, use, and administer an AO instance.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.4 KiB

import chalk from 'chalk'
import { repeatString } from './strings.js'
// Chalk styles
export const greenChalk = chalk.hex('#008800')
export const headerStyle = chalk.blue.bold.underline
export const manualTitleStyle = greenChalk.bold.underline
export const heading1 = chalk.bold.underline
export const heading2 = chalk.underline
// Preformatted phrases that can be used in backticked console.log strings
export const theAO = `the ${greenChalk.bold('AO')}`
export const theMenu = `the ${greenChalk.bold('Menu')}`
// Returns a colored capitalized status word
export const styledStatus = (fullWord, width) => {
const title = fullWord.toTitleCase()
const lookup = {
unknown: chalk.grey(title),
off: chalk.grey(title),
'not installed': chalk.grey(title),
blank: chalk.grey(title),
downloaded: chalk.yellow(title),
installed: chalk.blue(title),
initialized: chalk.green(title),
created: chalk.green(title),
enabled: greenChalk(title),
running: greenChalk(title),
synced: greenChalk(title),
error: chalk.red(title),
missing: chalk.red(title)
}
let styledWord = lookup[fullWord.toLowerCase()]
const halfDiff = (width - fullWord.length) / 2
const left = halfDiff % 2 === 0 ? repeatString(' ', halfDiff) : repeatString(' ', Math.ceil(halfDiff))
const right = repeatString(' ', Math.floor(halfDiff))
return left + styledWord + right
}