From 98a04d7c73f2969d6b08f4d925f53fb8e9f34c7e Mon Sep 17 00:00:00 2001
From: Masaki Kawabata Neto <masaki.kawabata@gmail.com>
Date: Thu, 29 Aug 2013 10:00:30 -0300
Subject: [PATCH 1/4] added help and status commands

switch structure enables many commands seamlessy.
also added some help and status command.
---
 console.php | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/console.php b/console.php
index 4aec5bdc24f..a2d4ab3562e 100644
--- a/console.php
+++ b/console.php
@@ -20,17 +20,32 @@ if (!OC::$CLI) {
 	exit(0);
 }
 
+$self = basename($argv[0]);
 if ($argc <= 1) {
-	echo "Usage:" . PHP_EOL;
-	echo " " . basename($argv[0]) . " <command>" . PHP_EOL;
-	exit(0);
+        $argv[1] = "help";
 }
 
 $command = $argv[1];
 array_shift($argv);
 
-if ($command === 'files:scan') {
-	require_once 'apps/files/console/scan.php';
-} else {
-	echo "Unknown command '$command'" . PHP_EOL;
+switch ($command) {
+        case 'files:scan':
+                require_once 'apps/files/console/scan.php';
+                break;
+        case 'status':
+                require_once 'status.php';
+                break;
+        case 'help':
+                echo "Usage:" . PHP_EOL;
+                echo " " . $self . " <command>" . PHP_EOL; 
+                echo PHP_EOL;
+                echo "Available commands:" . PHP_EOL;
+                echo " files:scan -> rescan filesystem" .PHP_EOL;
+                echo " status -> show some status information" .PHP_EOL;
+                echo " help -> show this help screen" .PHP_EOL;
+                break;
+        default:
+                echo "Unknown command '$command'" . PHP_EOL;
+                echo "For available commands type ". $self . " help" . PHP_EOL;
+                break;
 }

From 1dd18980ae171d9cd16ab95bdfb289b54ef6c34d Mon Sep 17 00:00:00 2001
From: Masaki Kawabata Neto <masaki.kawabata@gmail.com>
Date: Thu, 29 Aug 2013 10:03:58 -0300
Subject: [PATCH 3/4] enable usage with CLI interface

Added option to use the status.php with console.php via CLI
---
 status.php | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/status.php b/status.php
index 179fe3f49f2..88805ad6b19 100644
--- a/status.php
+++ b/status.php
@@ -33,8 +33,11 @@ try {
 		'version'=>implode('.', OC_Util::getVersion()),
 		'versionstring'=>OC_Util::getVersionString(),
 		'edition'=>OC_Util::getEditionString());
-
-	echo(json_encode($values));
+	if (OC::$CLI) {
+        	print_r($values);
+	} else {
+        	echo(json_encode($values));
+	}
 
 } catch (Exception $ex) {
 	OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);

From 04b9e77478a36b9ef9ed48a8181ed9195d47ec8a Mon Sep 17 00:00:00 2001
From: Masaki <masaki.kawabata@gmail.com>
Date: Thu, 29 Aug 2013 15:03:16 -0300
Subject: [PATCH 4/4] replace ident spaces with tabs

---
 console.php | 41 +++++++++++++++++++++--------------------
 status.php  |  4 ++--
 2 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/console.php b/console.php
index a2d4ab3562e..fbe09d9bb68 100644
--- a/console.php
+++ b/console.php
@@ -1,3 +1,4 @@
+
 <?php
 /**
  * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
@@ -22,30 +23,30 @@ if (!OC::$CLI) {
 
 $self = basename($argv[0]);
 if ($argc <= 1) {
-        $argv[1] = "help";
+	$argv[1] = "help";
 }
 
 $command = $argv[1];
 array_shift($argv);
 
 switch ($command) {
-        case 'files:scan':
-                require_once 'apps/files/console/scan.php';
-                break;
-        case 'status':
-                require_once 'status.php';
-                break;
-        case 'help':
-                echo "Usage:" . PHP_EOL;
-                echo " " . $self . " <command>" . PHP_EOL; 
-                echo PHP_EOL;
-                echo "Available commands:" . PHP_EOL;
-                echo " files:scan -> rescan filesystem" .PHP_EOL;
-                echo " status -> show some status information" .PHP_EOL;
-                echo " help -> show this help screen" .PHP_EOL;
-                break;
-        default:
-                echo "Unknown command '$command'" . PHP_EOL;
-                echo "For available commands type ". $self . " help" . PHP_EOL;
-                break;
+	case 'files:scan':
+		require_once 'apps/files/console/scan.php';
+		break;
+	case 'status':
+		require_once 'status.php';
+		break;
+	case 'help':
+		echo "Usage:" . PHP_EOL;
+		echo " " . $self . " <command>" . PHP_EOL;
+		echo PHP_EOL;
+		echo "Available commands:" . PHP_EOL;
+		echo " files:scan -> rescan filesystem" .PHP_EOL;
+		echo " status -> show some status information" .PHP_EOL;
+		echo " help -> show this help screen" .PHP_EOL;
+		break;
+	default:
+		echo "Unknown command '$command'" . PHP_EOL;
+		echo "For available commands type ". $self . " help" . PHP_EOL;
+		break;
 }
diff --git a/status.php b/status.php
index 88805ad6b19..88422100f14 100644
--- a/status.php
+++ b/status.php
@@ -34,9 +34,9 @@ try {
 		'versionstring'=>OC_Util::getVersionString(),
 		'edition'=>OC_Util::getEditionString());
 	if (OC::$CLI) {
-        	print_r($values);
+		print_r($values);
 	} else {
-        	echo(json_encode($values));
+		echo(json_encode($values));
 	}
 
 } catch (Exception $ex) {