Skip to content

Commit

Permalink
Update parameters for clippysay
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunnerLivio committed May 7, 2018
1 parent e43a0c9 commit d905794
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"

```

Expand Down
15 changes: 6 additions & 9 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ') ]);
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)]);
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 3 additions & 5 deletions renderer.js
Original file line number Diff line number Diff line change
@@ -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._);
});

0 comments on commit d905794

Please sign in to comment.