Comparing version 1.1.0 to 1.1.1
@@ -13,25 +13,34 @@ #!/usr/bin/env node | ||
const cmdConfigs = { | ||
host: { | ||
args: { | ||
type: 'string', | ||
requiresArg: true | ||
}, | ||
add: { | ||
alias: 'a', | ||
describe: 'add a host', | ||
array: true | ||
}, | ||
list: { | ||
alias: 'l', | ||
describe: 'list current hosts', | ||
boolean: true | ||
}, | ||
delete: { | ||
alias: 'd', | ||
describe: 'remove a host', | ||
boolean: true | ||
} | ||
} | ||
}; | ||
const cmdLists = Object.keys(cmdConfigs).reduce((accum, cmd) => { | ||
accum[cmd] = Object.keys(cmdConfigs[cmd]).sort(); | ||
return accum; | ||
}, {}); | ||
function hostCommand(yargs) { | ||
const argv = yargs | ||
.options({ | ||
'args': { | ||
type: 'string', | ||
requiresArg: true | ||
}, | ||
'add': { | ||
alias: 'a', | ||
describe: 'add a host', | ||
array: true | ||
}, | ||
'list': { | ||
alias: 'l', | ||
describe: 'list current hosts', | ||
boolean: true | ||
}, | ||
'delete': { | ||
alias: 'd', | ||
describe: 'remove a host', | ||
boolean: true | ||
} | ||
}) | ||
.options(cmdConfigs.host) | ||
.help('help') | ||
@@ -45,3 +54,2 @@ .argv; | ||
Object.keys(config.hosts).forEach(name => { | ||
@@ -66,2 +74,3 @@ const host = config.hosts[name]; | ||
Config.save(); | ||
console.log(`Host '${name}' added`); | ||
} else if (argv.remove) { | ||
@@ -81,3 +90,6 @@ const name = argv._[1]; | ||
const argv = yargs | ||
.command('host', 'add/update/remove hosts', hostCommand) | ||
.usage('Usage: eshost [command] [options] [input-file]') | ||
.command('host', `${cmdLists.host.join('/')} hosts`, hostCommand) | ||
.describe('e', 'eval a string') | ||
.alias('e', 'eval') | ||
.help('help') | ||
@@ -99,5 +111,5 @@ .argv; | ||
printHostResult(name, result); | ||
console.log("") | ||
console.log(""); | ||
}); | ||
}) | ||
}); | ||
} | ||
@@ -113,3 +125,3 @@ | ||
function printHostResult(name, result) { | ||
console.log(chalk.blue(`## ${name}`)) | ||
console.log(chalk.blue(`## ${name}`)); | ||
console.log(result.stdout.trim()); | ||
@@ -116,0 +128,0 @@ |
{ | ||
"name": "eshost", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Run scripts in any ECMAScript host", | ||
@@ -5,0 +5,0 @@ "bin": { |
@@ -9,2 +9,6 @@ ## ESHost | ||
Manage hosts with `eshost host`. Run files across all hosts using `eshost file.js`. Run a quick script using `eshost -e "script"`. | ||
#### Examples | ||
``` | ||
@@ -11,0 +15,0 @@ npm install -g eshost |
124
51
6001
6