Permalink
Browse files

[api] updated jitsu.commands.save to have optional app and filenames …

…in that order
  • Loading branch information...
1 parent ef3d731 commit c99964224a6661af296599845c2f167927412631 @blakmatrix blakmatrix committed Dec 11, 2012
Showing with 10 additions and 16 deletions.
  1. +10 −16 lib/jitsu/commands/env.js
View
@@ -21,12 +21,8 @@ env.usage = [
'jitsu env get <key>',
'jitsu env delete <key>',
'jitsu env clear',
- 'jitsu env save',
- 'jitsu env save <file>',
- 'jitsu env save <file> <app>',
- 'jitsu env load',
- 'jitsu env load <file>',
- 'jitsu env load <file> <app>'
+ 'jitsu env save [<app>] [<file>]',
+ 'jitsu env load [<app>] [<file>]'
];
//
@@ -270,8 +266,13 @@ env.save = function (appName, file, callback) {
if(arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
- file = args[0] || 'env.json';
- appName = args[1] || null;
+ appName = args[0] || null;
+ file = args[1] || 'env.json';
+ if (appName === null){
+ viewApp(callback, executeSave);
+ } else{
+ viewAppByName(appName, function(){jitsu.commands.env.save(null, appName, callback);}, executeSave);
+ }
}
function executeSave(err, app) {
@@ -289,7 +290,7 @@ env.save = function (appName, file, callback) {
if (result) {
fs.writeFile(file, JSON.stringify(app.env, null, 2), function (err) {
if (!err) {
- jitsu.log.info(file + ' written!');
+ jitsu.log.info(file.yellow + ' written!');
}
callback(err);
});
@@ -299,13 +300,6 @@ env.save = function (appName, file, callback) {
}
});
}
-
- if (!appName) {
- viewApp(callback, executeSave);
- }
- else {
- viewAppByName(appName, callback, executeSave);
- }
};
//

0 comments on commit c999642

Please sign in to comment.