Skip to content
Browse files

[minor] `jitsu databases *` handles wrong number of parameters better

  • Loading branch information...
1 parent e548924 commit c157adf230e2f72a564d30c020bea2b090528155 nicoreed committed Jul 13, 2011
Showing with 29 additions and 0 deletions.
  1. +29 −0 lib/jitsu/commands/databases.js
View
29 lib/jitsu/commands/databases.js
@@ -20,6 +20,19 @@ databases.usage = [
];
databases.create = function (databaseType, databaseName, callback) {
+ if (!callback) {
+ winston.error('You need to pass a database name and type');
+ winston.error('jitsu databases create <database type> <database name>');
+ if (!databaseName) {
+ callback = databaseType;
+ }
+ else {
+ callback = databaseName;
+ }
+ return callback();
+ }
+
+
// Make sure that the user is passing a valid database type
if ( ['couch', 'redis', 'mongo'].indexOf(databaseType) === -1 ) {
winston.error('Invalid database type ' + databaseType.red);
@@ -54,6 +67,15 @@ databases.create.usage = [
]
databases.get = function (databaseName, callback) {
+ if (!callback) {
+ winston.error('You need to pass a database name');
+ winston.error('jitsu databases get <database name>');
+ winston.error('If you want to get a list of all the databases run:');
+ winston.error('jitsu databases list');
+ callback = databaseName;
+ return callback();
+ }
+
jitsu.databases.get(databaseName, function (err, results) {
if (err) {
if (err.statusCode === '404') {
@@ -104,6 +126,13 @@ databases.list.usage = [
]
databases.destroy = function (databaseName, callback) {
+ if (!callback) {
+ winston.error('You need to pass a database name');
+ winston.error('jitsu databases destroy <database name>');
+ callback = databaseName;
+ return callback();
+ }
+
jitsu.databases.destroy(databaseName, function (err) {
if (err) {
winston.error('Database could not be destroyed.');

0 comments on commit c157adf

Please sign in to comment.
Something went wrong with that request. Please try again.