Browse files

[api] App and Log commands can now accept fully qualified application…

… names
  • Loading branch information...
1 parent 2b84bca commit 371732cbb6d5d79eadf36a824cd6fb8338a11528 @Marak Marak committed Nov 18, 2011
Showing with 52 additions and 13 deletions.
  1. +44 −10 lib/jitsu/commands/apps.js
  2. +8 −3 lib/jitsu/commands/logs.js
View
54 lib/jitsu/commands/apps.js
@@ -151,13 +151,14 @@ apps.deploy.usage = [
// using `name` if supplied and falling back to `package.name`.
//
apps.create = function (target, callback) {
+
+ var name;
+
if (!callback) {
callback = target;
target = null;
}
-
- var name;
-
+
function executeCreate (err, pkg) {
if (err) {
winston.error(err);
@@ -233,10 +234,17 @@ apps.create.usage = [
// #### @callback {function} Continuation to pass control to when complete.
// Lists the applications for the authenticated user.
//
-apps.list = function (callback) {
+apps.list = function (username, callback) {
winston.info('Listing apps');
- jitsu.apps.list(function (err, apps) {
+
+ if(!callback){
+ callback = username;
+ username = jitsu.config.get('username');
+ }
+
+ jitsu.apps.list(username, function (err, apps) {
if (err) {
+ console.log(err);
return callback(err);
}
@@ -282,6 +290,11 @@ apps.list.usage = [
// If no name is supplied this will view the application in the current directory.
//
apps.view = function (name, callback) {
+
+ if(name.search('/') === -1){
+ name = jitsu.config.get('username') + '/' + name;
+ }
+
function executeView() {
jitsu.apps.view(name, function (err, app) {
if (err) {
@@ -324,11 +337,11 @@ apps.view.usage = [
// Lists the applications for the authenticated user.
//
apps.update = function (name, callback) {
- if (!callback) {
- callback = name;
- name = null;
+
+ if(name.search('/') === -1){
+ name = jitsu.config.get('username') + '/' + name;
}
-
+
winston.silly('Reading package.json in ' + process.cwd());
jitsu.package.tryRead(process.cwd(), callback, function (pkg) {
name = name || pkg.name;
@@ -371,6 +384,11 @@ apps.update.usage = [
// this will destroy the application in the current directory.
//
apps.destroy = function (name, callback) {
+
+ if(name.search('/') === -1){
+ name = jitsu.config.get('username') + '/' + name;
+ }
+
function executeDestroy() {
winston.info('Destroying app ' + name.magenta);
jitsu.apps.destroy(name, function (err) {
@@ -408,7 +426,13 @@ apps.destroy.usage = [
// Starts the application specified by `name`. If no name is supplied
// this will start the application in the current directory.
//
-apps.start = function (name, callback) {
+apps.start = function (name, callback) {
+
+ if(name.search('/') === -1){
+ name = jitsu.config.get('username') + '/' + name;
+ }
+
+ console.log(name);
function executeStart() {
winston.info('Starting app ' + name.magenta);
jitsu.apps.start(name, function (err) {
@@ -458,6 +482,11 @@ apps.start.usage = [
// this will restart the application in the current directory.
//
apps.restart = function (name, callback) {
+
+ if(name.search('/') === -1){
+ name = jitsu.config.get('username') + '/' + name;
+ }
+
function executeRestart() {
winston.info('Restarting app ' + name.magenta);
jitsu.apps.restart(name, function (err) {
@@ -500,6 +529,11 @@ apps.restart.usage = [
// this will stop the application in the current directory.
//
apps.stop = function (name, callback) {
+
+ if(name.search('/') === -1){
+ name = jitsu.config.get('username') + '/' + name;
+ }
+
function executeStop() {
winston.info('Stopping app ' + name.magenta);
jitsu.apps.stop(name, function (err) {
View
11 lib/jitsu/commands/logs.js
@@ -32,7 +32,7 @@ logs.all = function (amount, callback) {
amount = 10;
}
- jitsu.logs.byUser(amount, function (err, apps) {
+ jitsu.logs.byUser(jitsu.config.get('username'), amount, function (err, apps) {
if (err) {
return callback(err);
}
@@ -82,6 +82,11 @@ logs.app = function (appName, amount, callback) {
// This is defined so that it can get called once all the arguments are
// sorted out.
var byApp = function (appName, amount, callback) {
+
+ if(appName.search('/') === -1){
+ appName = jitsu.config.get('username') + '/' + appName;
+ }
+
jitsu.logs.byApp(appName, amount, function (err, results) {
if (err) {
return callback(err);
@@ -108,14 +113,14 @@ logs.app = function (appName, amount, callback) {
} else {
// Plug in the app name and go
appName = result["app name"];
- byApp(appName, 10, callback);
+ byApp(appName, 100, callback);
}
});
}
});
} else if (callback === undefined) {
callback = amount;
- amount = 10;
+ amount = 100;
byApp(appName, amount, callback);
} else {
byApp(appName, amount, callback);

0 comments on commit 371732c

Please sign in to comment.