diff --git a/README.md b/README.md index e3fe89f..eec98ab 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,11 @@ After the [installation](#install), `clippy-say` can be used as described. ```bash # Run clippy -clippy-say +clippysay # Run Merlin and let him speak "Hello World" # Possible characters: "Clippy", "Merlin", "Rover" and "Links" -clippy-say Merlin --speak "Hello World" +clippysay "Hello World" --character "Hello World" ``` diff --git a/cli.js b/cli.js index c740cb7..417e8b5 100755 --- a/cli.js +++ b/cli.js @@ -2,14 +2,11 @@ const electron = require('electron') const proc = require('child_process') -const argv = require('minimist')(process.argv.slice(2)) -let params; +const argv = require('minimist')(process.argv.slice(2)); -if(argv._.length) { - params = Object.keys(argv).map(key => key === '_' ? argv[key] : `--${key} ${argv[key]}`).join(' '); -} else { - // Default value - params = 'Clippy'; -} +const characters = ['Merlin', 'Clippy', 'Rover', 'Links']; -proc.spawn(electron, ['.', ...params.split(' ') ]); \ No newline at end of file +let character = argv.c || argv.character || 'Clippy'; +if(characters.indexOf(character) === -1) return console.error(`"${character}" is not a valid character. Use ${characters.join(', ')} instead`); + +proc.spawn(electron, ['.', ...process.argv.slice(2)]); \ No newline at end of file diff --git a/package.json b/package.json index 889b85b..37480df 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { "name": "clippy-say", - "version": "0.0.1", + "version": "0.0.2", "description": "", "main": "index.js", "scripts": { "start": "node cli.js" }, "bin": { - "clippy-say": "./cli.js" + "clippysay": "./cli.js" }, "author": "", "license": "ISC", diff --git a/renderer.js b/renderer.js index 109a1e6..ff7711a 100644 --- a/renderer.js +++ b/renderer.js @@ -1,12 +1,10 @@ const electron = require('electron'); const argv = require('minimist')(electron.remote.process.argv.slice(2)); -const speak = argv.s || argv.speak; +const character = argv.c || argv.character || 'Clippy'; const clippy = require('clippyjs'); -clippy.load(argv._[0], agent => { +clippy.load(character, agent => { agent.show(); - if(speak) { - agent.speak(speak); - } + agent.speak(...argv._); }); \ No newline at end of file