diff --git a/README.md b/README.md index b87ecb5..40afc2d 100644 --- a/README.md +++ b/README.md @@ -3,18 +3,18 @@ ## Setup ```bash -bun install +bun ``` ## To Build ```bash -bun run index.js +bun index.ts ``` ## To Live Preview ```bash -while sleep 1 ; do find . -name '*.ts' | entr bun index.ts ; done +bun --watch index.ts preview ``` ## To Run Tests diff --git a/bun.lockb b/bun.lockb index a98e11a..5fed2ff 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/index.ts b/index.ts index a454417..541ceff 100644 --- a/index.ts +++ b/index.ts @@ -1,20 +1,28 @@ -import chalk from 'chalk' -import colors, { pit, text, darkTeal, darkOrange, lightOrange, darkPurple } from './src/palette' -import Color from './src/helpers/color' +#!/usr/bin/env node +import { Command } from 'commander' +import previewList from './src/preview/cli-list' +import previewSnippet from './src/preview/cli-snippet' -function log(color: Color) { - console.log( - chalk.hex(color.toHex()).bold('■ T'), - chalk.hex(text.toHex()).bold(color.name) - ) -} +const program = new Command(); + +program + .name('verdigris') + .description('Mining up the very best Color Palette') + .version('0.0.1') + +program + .command('preview') + .description('TODO') + .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.parse(); -colors.forEach(log) -console.log( - chalk - .bgHex(pit.toHex()) - .hex(text.toHex()) - .visible( - `${chalk.hex(darkTeal.toHex()).visible('const')} ${chalk.hex(darkOrange.toHex()).visible('myFunc')} ${chalk.hex(lightOrange.toHex()).visible('=')} (isAwesome: boolean) => return 'yep'` - ) -) diff --git a/package.json b/package.json index 7d0bf0c..b168dca 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "devDependencies": { "@types/bun": "latest", "chalk": "^5.6.2", - "color-convert": "^3.1.2" + "color-convert": "^3.1.2", + "commander": "^14.0.1" }, "peerDependencies": { "typescript": "^5.0.0" diff --git a/src/preview/cli-list.ts b/src/preview/cli-list.ts new file mode 100644 index 0000000..f355308 --- /dev/null +++ b/src/preview/cli-list.ts @@ -0,0 +1,12 @@ +import chalk from 'chalk' +import colors, { text } from '../palette' +import Color from '../helpers/color' + +export function log(color: Color) { + console.log( + chalk.hex(color.toHex()).bold('■ T'), + chalk.hex(text.toHex()).bold(color.name) + ) +} + +export default () => colors.forEach(log) diff --git a/src/preview/cli-snippet.ts b/src/preview/cli-snippet.ts new file mode 100644 index 0000000..28755a6 --- /dev/null +++ b/src/preview/cli-snippet.ts @@ -0,0 +1,33 @@ +import chalk from 'chalk' +import { pit, text, darkTeal, darkOrange, lightOrange, darkPurple, lightPurple, darkBlue, darkGreen, stope } from '../palette' + +const bg = chalk.bgHex(pit.toHex()).hex(text.toHex()) +const chalkDefinition = chalk.hex(darkTeal.toHex()) +const chalkVariable = chalk.hex(darkOrange.toHex()) +const chalkAssignments = chalk.hex(lightOrange.toHex()) +const chalkParenthesis = chalk.hex(darkPurple.toHex()) +const chalkParameter = chalk.hex(lightPurple.toHex()) +const chalkType = chalk.hex(darkBlue.toHex()) +const chalkReturn = chalk.hex(darkGreen.toHex()) +const chalkComment = chalk.italic.hex(stope.toHex()) + +export default () => { + console.log( + bg(` +${chalkDefinition('const')} + ${chalkVariable('myFunc')} + ${chalkAssignments('=')} + ${chalkParenthesis('\(')} +${chalkParameter('isAwesome')} +: + ${chalkType('boolean')} +${chalkParenthesis('\)')} +: + ${chalkType('string')} + ${chalkAssignments('=>')} + ${chalkReturn('return')} + 'yep!' + ${chalkComment('# cool!')} +`).split('\n').join('') + ) +}