Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[api][fix] made/added argument currying congruent in functions
  • Loading branch information
blakmatrix committed Sep 18, 2012
1 parent 11012cc commit d955a5e
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/jitsu/commands/apps.js
Expand Up @@ -230,7 +230,7 @@ apps.create = function (target, callback) {
// Allows arbitrary amount of arguments
//
if(arguments.length) {
args = utile.args(arguments);
var args = utile.args(arguments);
callback = args.callback;
target = args[0] || null;
}
Expand Down
69 changes: 59 additions & 10 deletions lib/jitsu/commands/env.js
Expand Up @@ -5,8 +5,9 @@
*
*/

var jitsu = require('../../jitsu');

var jitsu = require('../../jitsu'),
utile = require('utile');

var env = exports;

env.usage = [
Expand All @@ -26,10 +27,20 @@ env.usage = [
// #### @key {string} Key to set in jitsu config.
// #### @value {string} Value to set the key to.
// #### @callback {function} Continuation to pass control to when complete
// Sets the specified `key` in the environment variables to `value` for
// Sets the specified `key` in the environment variables to `value` for
// the application in the current directory.
//
env.set = function (appName, key, value, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
appName = args[0] || null;
key = args[1] || null;
value = args[2] || null;
}

if (value === null) {
if (key === null) {
Expand Down Expand Up @@ -72,11 +83,21 @@ env.set.usage = [
// application in the current directory.
//
env.get = function (appName, key, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
appName = args[0] || null;
key = args[1] || null;
}

if (key === null) {
key = appName;
return viewApp(callback, gotEnv);
}

viewAppByName(appName, callback, gotEnv);

function gotEnv(err, app) {
Expand Down Expand Up @@ -108,11 +129,21 @@ env.get.usage = [
// application in the current directory.
//
env.delete = function (appName, key, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
appName = args[0] || null;
key = args[1] || null;
}

if (key === null) {
key = appName;
return viewApp(callback, deleteKey);
}

viewAppByName(appName, callback, deleteKey);

function deleteKey(err, app) {
Expand All @@ -139,10 +170,19 @@ env.delete.usage = [
//
// ### function list (callback)
// #### @callback {function} Continuation to pass control to when complete
// Lists all environment variables for the application in the
// Lists all environment variables for the application in the
// current directory.
//
env.list = function (appName, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
appName = args[0] || null;
}

function executeList(err, app) {
if (!app.env || Object.keys(app.env).length === 0) {
jitsu.log.warn('No environment variables for ' + app.name.magenta);
Expand All @@ -153,8 +193,8 @@ env.list = function (appName, callback) {
jitsu.inspect.putObject(app.env);
callback();
}
if (!appName) {

if (!appName) {
viewApp(callback, executeList);
}
else {
Expand All @@ -180,18 +220,27 @@ env.list.usage = [
];

env.clear = function (appName, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
appName = args[0] || null;
}

if (appName === null) {
return viewApp(callback, clearEnv);
}

viewAppByName(appName, callback, clearEnv);

function clearEnv(err, app) {
if (!app.env || Object.keys(app.env).length === 0) {
jitsu.log.warn('No environment variables for ' + app.name.magenta);
return callback();
}

jitsu.log.warn('All environment variables for ' + app.name.magenta + ' will be deleted.');
jitsu.prompt.get(['yesno'], function (err, result) {
return err
Expand Down

0 comments on commit d955a5e

Please sign in to comment.