54 lines
1.7 KiB
JavaScript
54 lines
1.7 KiB
JavaScript
#!/usr/bin/env node
|
|
import { Command } from 'commander'
|
|
import { timerToSeconds } from './src/helpers/math';
|
|
import previewList from './src/preview/cli-list'
|
|
import previewSnippet from './src/preview/cli-snippet'
|
|
import buildTOML from './src/build/toml'
|
|
import buildYAML from './src/build/yaml'
|
|
import buildKitty from './ports/kitty/src/build'
|
|
import buildNeovim from './ports/neovim/src/build'
|
|
|
|
const program = new Command();
|
|
|
|
async function log(isVerbose: true, file: string, timer: [number, number]) {
|
|
const time: string = isVerbose ? ` ${timerToSeconds(timer)} seconds` : ''
|
|
console.info(`${file}${time}`)
|
|
}
|
|
|
|
program
|
|
.name('verdigris')
|
|
.description('Mining up the very best Color Palette')
|
|
.version('0.0.1')
|
|
|
|
program
|
|
.command('preview')
|
|
.description('stdout some examples')
|
|
.option('-v, --verbose', 'additional logs')
|
|
.option('--no-list', 'do not show colors as a list')
|
|
.option('--no-snippet', 'do not a code snippet')
|
|
.action((options) => {
|
|
if (options.verbose) console.info('Previewing Color Palette')
|
|
if (options.verbose) console.info('List:')
|
|
if (options.list) previewList()
|
|
if (options.verbose) console.info('Code Example:')
|
|
if (options.snippet) previewSnippet()
|
|
});
|
|
|
|
program
|
|
.command('build')
|
|
.description('compile toml and other consumable formats')
|
|
.option('-v, --verbose', 'additional logs')
|
|
.action(async (options) => {
|
|
const timer = process.hrtime()
|
|
|
|
if (options.verbose) console.info('Building Direct Exports...')
|
|
log(options.verbose, await buildTOML(), timer)
|
|
log(options.verbose, await buildYAML(), timer)
|
|
|
|
if (options.verbose) console.info('Building Ports...')
|
|
log(options.verbose, await buildKitty(), timer)
|
|
// log(options.verbose, await buildNeovim(), timer)
|
|
});
|
|
|
|
program.parse();
|
|
|