diff --git a/README.md b/README.md index 5427c49..a413fbd 100644 --- a/README.md +++ b/README.md @@ -6,32 +6,31 @@ A Node CLI Tool for Sphero BB8 Robot using the [Sphero Javascript SDK](http://sd # Install Not yet on npm so you'll have to do it the good'ol fasioned way with a cheeky git clone -* `git clone git@github.com:mintuz/bb8-commander.git` -* `npm install` -* `node index.js setup` +* `npm install -g bb8-commander` +* `bb8 setup` * Use commands below # Commands ### Utility Commands -* `node index.js setup` - Command to save your BB8 Unit UUID to config for future reference -* `node index.js disconnect` - Command to disconnect from your BB8 Unit +* `bb8 setup` - Command to save your BB8 Unit UUID to config for future reference +* `bb8 disconnect` - Command to disconnect from your BB8 Unit ### Action Commands -* `node index.js disco` - Command to turn your BB8 Unit into a shining disco ball in the night -* `node index.js roll` - A simple command to make your BB8 Randomly roll in any direction. -* `node index.js desk-buddy` - A command to keep you company whilst working at your desk. Place in it's charging station to watch its head move round randomly. -* `node index.js weather --city="manchester" --country="uk" --api-key="ABCD"` - Command to turn your BB8 Unit into your very own weather reporter, uses OpenWeather so be sure to get your own API key -* `node index.js tweet --hash-tag="bb8" --delay=5000` - Command to search twitter and run the first hashtag it finds as a command. Eg a tweet "#disco #bb8" would run the `disco` command --consumer-key xxx --consumer-secret xxx --access-token-key xxx --access-token-secret xxx -* `node index.js power` - A command to get details of the battery state. -* `node index.js drive` - A command to enable you to take input from the keyboard and 'drive' your BB-8 with the arrow keys. -* `node index.js express --port=4000` - Command to run an express server which has a single POST endpoint which you can send a JSON object to. See below for more details. +* `bb8 disco` - Command to turn your BB8 Unit into a shining disco ball in the night +* `bb8 roll` - A simple command to make your BB8 Randomly roll in any direction. +* `bb8 desk-buddy` - A command to keep you company whilst working at your desk. Place in it's charging station to watch its head move round randomly. +* `bb8 weather --city="manchester" --country="uk" --api-key="ABCD"` - Command to turn your BB8 Unit into your very own weather reporter, uses OpenWeather so be sure to get your own API key +* `bb8 tweet --hash-tag="bb8" --delay=5000` - Command to search twitter and run the first hashtag it finds as a command. Eg a tweet "#disco #bb8" would run the `disco` command --consumer-key xxx --consumer-secret xxx --access-token-key xxx --access-token-secret xxx +* `bb8 power` - A command to get details of the battery state. +* `bb8 drive` - A command to enable you to take input from the keyboard and 'drive' your BB-8 with the arrow keys. +* `bb8 express --port=4000` - Command to run an express server which has a single POST endpoint which you can send a JSON object to. See below for more details. ### Express Server Having the ability to run an Express server to issue commands to the BB8 unit opens up a bunch of possibilities. One of the main benefits of having an Express server is that you can integrate into [IFTTT](https://ifttt.com/) and at that point, you have entered the Internet of things. -To get started is really easy, all you need to do is run `node index.js express --port=4000` adn once your BB8 is connected, an Express server will be started. +To get started is really easy, all you need to do is run `bb8 express --port=4000` adn once your BB8 is connected, an Express server will be started. You can then send commands directly to it via a POST request. It supports any SpheroSDK command as well as custom commands we have created. See below for some examples. diff --git a/bin/index.js b/bin/index.js new file mode 100644 index 0000000..1783b36 --- /dev/null +++ b/bin/index.js @@ -0,0 +1,114 @@ +var program = require('commander'), + packageFile = require('../package.json'), + executeCommand = require('../libs/execute-command'); + +program.version(packageFile.version); + +// Utility Actions + +program + .command('setup') + .description('Command to setup BB8 With your Mac') + .action(require('../commands/setup')); + +program + .command('disconnect') + .description('Command to disconnect from your BB8 Unit') + .action(function () { + executeCommand('disconnect'); + }); + +// Real Actions + +program + .command("dance") + .description("dance dance BB-8") + .action(function () { + executeCommand("dance"); + }); + +program + .command('disco') + .description('Command to make your BB8 Unit A disco ball') + .action(function () { + executeCommand('disco'); + }); + +program + .command('weather') + .description('Command to get the weather colour from your BB8 Unit') + .option('-c, --city ', 'City name such as manchester') + .option('-cc, --country ', 'Country name such as uk') + .option('-t, --access-token ', 'API Key') + .action(function(options) { + executeCommand('weather', options); + }); + +program + .command('github') + .description('Command to get notifications of new issues and PRs') + .option('-t, --access-token ', 'API Key') + .action(require('github')); + +program + .command('roll') + .description('BB8 will roll!') + .action(function () { + executeCommand('roll'); + }); + + +program + .command('tweet') + .description('BB8 will respond to tweets!') + .option('-#, --hash-tag ', 'Hashtag to search for. Defaults to "#bb8bbc"') + .option('-d, --delay ', 'Interval delay for retrieving new tweets. Defaults to 10000') + .option('--consumer-key ', 'Twitter api consumer key') + .option('--consumer-secret ', 'Twitter api consumer secret') + .option('--access-token-key ', 'Twitter api access token key') + .option('--access-token-secret ', 'Twitter api access token secret') + .action(function (options) { + executeCommand('tweet', options); + }); + +program + .command('express') + .description('Command to setup express server') + .option('-p, --port ', 'Port to run express on. Defaults to 3000') + .action(function (options) { + executeCommand('express', options); + }); + +program + .command('desk-buddy') + .description('Command to keep you company whilst working at your desk. Place your BB8 in the charging station.') + .action(function (options) { + executeCommand('desk-buddy'); + }); + +program + .command('power') + .description('Command to get the power state of the BB-8') + .action(function (options) { + executeCommand('power'); + }); + +program + .command('gestures') + .description('Some gestures for your BB-8') + .action(function (options) { + executeCommand('gestures'); + }); + +program + .command('drive') + .description('Command to accept keyboard input--use arrow keys') + .action(function (options) { + executeCommand('drive'); + }); + +try { + program.parse(process.argv); +} catch (e) { + console.error(e); +} diff --git a/index.js b/index.js index 9c18921..b45a074 100644 --- a/index.js +++ b/index.js @@ -1,114 +1,2 @@ -var program = require('commander'), - packageFile = require('./package.json'), - executeCommand = require('./libs/execute-command'); - -program.version(packageFile.version); - -// Utility Actions - -program - .command('setup') - .description('Command to setup BB8 With your Mac') - .action(require('./commands/setup')); - -program - .command('disconnect') - .description('Command to disconnect from your BB8 Unit') - .action(function () { - executeCommand('disconnect'); - }); - -// Real Actions - -program - .command("dance") - .description("dance dance BB-8") - .action(function () { - executeCommand("dance"); - }); - -program - .command('disco') - .description('Command to make your BB8 Unit A disco ball') - .action(function () { - executeCommand('disco'); - }); - -program - .command('weather') - .description('Command to get the weather colour from your BB8 Unit') - .option('-c, --city ', 'City name such as manchester') - .option('-cc, --country ', 'Country name such as uk') - .option('-t, --access-token ', 'API Key') - .action(function(options) { - executeCommand('weather', options); - }); - -program - .command('github') - .description('Command to get notifications of new issues and PRs') - .option('-t, --access-token ', 'API Key') - .action(require('github')); - -program - .command('roll') - .description('BB8 will roll!') - .action(function () { - executeCommand('roll'); - }); - - -program - .command('tweet') - .description('BB8 will respond to tweets!') - .option('-#, --hash-tag ', 'Hashtag to search for. Defaults to "#bb8bbc"') - .option('-d, --delay ', 'Interval delay for retrieving new tweets. Defaults to 10000') - .option('--consumer-key ', 'Twitter api consumer key') - .option('--consumer-secret ', 'Twitter api consumer secret') - .option('--access-token-key ', 'Twitter api access token key') - .option('--access-token-secret ', 'Twitter api access token secret') - .action(function (options) { - executeCommand('tweet', options); - }); - -program - .command('express') - .description('Command to setup express server') - .option('-p, --port ', 'Port to run express on. Defaults to 3000') - .action(function (options) { - executeCommand('express', options); - }); - -program - .command('desk-buddy') - .description('Command to keep you company whilst working at your desk. Place your BB8 in the charging station.') - .action(function (options) { - executeCommand('desk-buddy'); - }); - -program - .command('power') - .description('Command to get the power state of the BB-8') - .action(function (options) { - executeCommand('power'); - }); - -program - .command('gestures') - .description('Some gestures for your BB-8') - .action(function (options) { - executeCommand('gestures'); - }); - -program - .command('drive') - .description('Command to accept keyboard input--use arrow keys') - .action(function (options) { - executeCommand('drive'); - }); - -try { - program.parse(process.argv); -} catch (e) { - console.error(e); -} +module.exports.setup = require('./commands/setup'); +module.exports.executeCommand = require('./libs/execute-command'); \ No newline at end of file diff --git a/package.json b/package.json index a35ba85..1ff7d55 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,11 @@ { "name": "bb8-commander", - "version": "1.3.0", + "version": "2.0.0", "description": "A Node CLI Tool for Sphero BB8 Robot.", "main": "index.js", + "bin": { + "bb8": "bin/index.js" + }, "repository": { "type": "git", "url": "git+https://github.com/mintuz/bb8-commander.git" @@ -10,6 +13,10 @@ "keywords": [ "BB8", "Sphero", + "BB8 Commander", + "BB8 Javascript", + "BB8 Robot", + "Sphero Robot", "Robot" ], "author": "",