From 473c55aa064cce3f72c7a6b72f7470a77cb5056c Mon Sep 17 00:00:00 2001 From: nthnn Date: Sun, 20 Aug 2023 12:04:57 +0800 Subject: [PATCH] Created cli-tool for Yttria project tooling. --- cli-tool/cli-tool.ts | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 cli-tool/cli-tool.ts diff --git a/cli-tool/cli-tool.ts b/cli-tool/cli-tool.ts new file mode 100644 index 0000000..1c2af62 --- /dev/null +++ b/cli-tool/cli-tool.ts @@ -0,0 +1,51 @@ +import { hideBin } from 'yargs/helpers'; + +import colors from 'colors'; +import yargs from 'yargs'; + +function printBanner(args: any) { + console.log(); + console.log('┌──────────────────────────────────────┐'); + console.log('│ │'); + + // Here comes the wizardry. + console.log( + '│' + ' ▀▀▌' + '───────'.gray + '▐▀▀' + ' │\n' + + '│' + ' ▄▀' + '░'.blue + '◌'.bold + '░░░░░░░'.blue + '▀▄' + ' ┓┏ •'.cyan.bold + ' │\n' + + '│' + ' ▐' + '░░'.blue + '◌'.bold + '░'.blue + '▄▀██▄█' + '░░░'.blue + '▌' + ' ┗┫ ╋ ╋ ┏┓ ┓ ┏┓'.cyan.bold + ' │\n' + + '│' + ' ▐' + '░░░'.blue + '▀████▀▄' + '░░░'.blue + '▌' + ' ┗┛ ┗ ┗ ┛ ┗ ┗┻'.cyan.bold + ' │\n' + + '│' + ' ▐' + '░░░░░░░░░░░░░'.blue + '▌ ' + ' CLI Tool '.bgRed + ' │\n' + + '│' + ' ▀▄▄▄▄▄▄▄▄▄▄▄▀' + ' v0.0.1'.yellow.bold + ' │\n' + + '│ │' + ); + + if(args.help || args.h || + args._.length == 0) { + + console.log( + '├──────────────────────────────────────┤\n' + + '│ Use ' + '-h'.italic + ' to print help screen. │\n' + + '│ │\n' + + '│ For more details, visit: │\n' + + '│ ' + 'https://nthnn.github.io/yttria-lang'.underline + ' │\n' + + '└──────────────────────────────────────┘\n' + ); + } + else console.log('└──────────────────────────────────────┘\n'); +} + +function main(): void { + const args = yargs(hideBin(process.argv)) + .option('help', { + alias: 'h', + type: 'boolean' + }) + .showHelp(()=> { }) + .exitProcess(false) + .argv; + + colors.enable(); + printBanner(args); +} + +main(); \ No newline at end of file