diff --git a/README.md b/README.md index 3209165..97680b7 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Usage: blahaj [options] [command] Options: -V, --version output the version number -c, --classic output the blahaj in legacy way by jimp (low quality so you are warned!) - -b, --baby output the baby blahaj + -b, --baby output the baby blahaj (use classic keyword after --baby argument if you want render it by legacy way) -h, --help display help for command Commands: @@ -31,6 +31,8 @@ $ blahaj --classic $ blahaj --baby +$ blahaj --baby classic + $ blahaj ascii_art --default # (or --pride) ``` diff --git a/src/index.ts b/src/index.ts index f517dd8..918ae4f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -125,16 +125,31 @@ const main = async (_arguments: string[]) => { program .option("-b, --baby", "output the baby blahaj") .action(async () => { - console.log( - await draw( - BABY_BLAHAJ_URL, - { - width: 80, - height: 80, - }, - ), - ); - process.exit(0); + if (_arguments.includes("classic")) { + console.log( + await draw( + BABY_BLAHAJ_URL, + { + width: 80, + height: 80, + }, + ), + ); + process.exit(0); + } + + checkIfCommandExists("viu --version") + .then((exists) => { + if (exists) { + spawn(`curl`, [`${BABY_BLAHAJ_URL} -o /tmp/baby_blahaj.jpg`]); + console.log(); + spawn("viu", ["/tmp/baby_blahaj.jpg"], { stdio: "inherit" }); + process.exit(0); + } else { + console.error("❌ viu command not found! Please install it from https://github.com/atanunq/viu"); + process.exit(1); + } + }); }); program.parse(_arguments);