Skip to content
This repository
Browse code

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

  • Loading branch information...
commit c157adf230e2f72a564d30c020bea2b090528155 1 parent e548924
Nico Reed nicoreed authored

Showing 1 changed file with 29 additions and 0 deletions. Show diff stats Hide diff stats

  1. +29 0 lib/jitsu/commands/databases.js
29 lib/jitsu/commands/databases.js
@@ -20,6 +20,19 @@ databases.usage = [
20 20 ];
21 21
22 22 databases.create = function (databaseType, databaseName, callback) {
  23 + if (!callback) {
  24 + winston.error('You need to pass a database name and type');
  25 + winston.error('jitsu databases create <database type> <database name>');
  26 + if (!databaseName) {
  27 + callback = databaseType;
  28 + }
  29 + else {
  30 + callback = databaseName;
  31 + }
  32 + return callback();
  33 + }
  34 +
  35 +
23 36 // Make sure that the user is passing a valid database type
24 37 if ( ['couch', 'redis', 'mongo'].indexOf(databaseType) === -1 ) {
25 38 winston.error('Invalid database type ' + databaseType.red);
@@ -54,6 +67,15 @@ databases.create.usage = [
54 67 ]
55 68
56 69 databases.get = function (databaseName, callback) {
  70 + if (!callback) {
  71 + winston.error('You need to pass a database name');
  72 + winston.error('jitsu databases get <database name>');
  73 + winston.error('If you want to get a list of all the databases run:');
  74 + winston.error('jitsu databases list');
  75 + callback = databaseName;
  76 + return callback();
  77 + }
  78 +
57 79 jitsu.databases.get(databaseName, function (err, results) {
58 80 if (err) {
59 81 if (err.statusCode === '404') {
@@ -104,6 +126,13 @@ databases.list.usage = [
104 126 ]
105 127
106 128 databases.destroy = function (databaseName, callback) {
  129 + if (!callback) {
  130 + winston.error('You need to pass a database name');
  131 + winston.error('jitsu databases destroy <database name>');
  132 + callback = databaseName;
  133 + return callback();
  134 + }
  135 +
107 136 jitsu.databases.destroy(databaseName, function (err) {
108 137 if (err) {
109 138 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.