From c924b4c252cdaedc37180e5832291875f21caf14 Mon Sep 17 00:00:00 2001 From: Vinicius Rezende Date: Thu, 12 Oct 2023 02:14:47 -0300 Subject: [PATCH] Support multiple/random parrots --- README.md | 8 ++++++++ src/index.js | 13 ++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 02c1760..02f8c38 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,14 @@ or `echo 'yay' | parrotsay` +## Different parrots + +`parrotsay --parrot-random yay` + +or + +`echo 'yay' | parrotsay --parrot-white-eyed-conure` + ## Related - [parrotsay-api](https://github.com/matheuss/parrotsay-api) - API for this module diff --git a/src/index.js b/src/index.js index 4e2133c..c9cf3c6 100644 --- a/src/index.js +++ b/src/index.js @@ -8,15 +8,22 @@ const pkg = require('../package.json') updateNotifier({pkg}).notify() -const input = minimist(process.argv.slice(2))._.join(' ') +let parrotArg = process.argv[2]; +if ( parrotArg.startsWith('--parrot-') ) { + parrotArg = parrotArg.replace('--parrot-', ''); + delete(process.argv[2]); +} else { + parrotArg = undefined; +} +const input = minimist(process.argv.slice(2))._.join(' ') if (input) { - parrot(input) + parrot(input, parrotArg) .then(console.log) .catch(console.error) } else { getStdin().then(string => { - parrot(string.trim() || 'LET\'S PARTY') + parrot(string.trim() || 'LET\'S PARTY', parrotArg) .then(console.log) .catch(console.error) })