Author: anovarini
Date: Sun Mar 11 00:36:04 2012
New Revision: 1299316
URL: http://svn.apache.org/viewvc?rev=1299316&view=rev
Log:
Fixed a bug on the Connect command, added Disconnect
Added:
incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/Domains.groovy
incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/SetDomain.groovy
Modified:
incubator/kitty/trunk/src/main/groovy/org/apache/kitty/CmdShell.groovy
Modified: incubator/kitty/trunk/src/main/groovy/org/apache/kitty/CmdShell.groovy
URL:
http://svn.apache.org/viewvc/incubator/kitty/trunk/src/main/groovy/org/apache/kitty/CmdShell.groovy?rev=1299316&r1=1299315&r2=1299316&view=diff
==============================================================================
--- incubator/kitty/trunk/src/main/groovy/org/apache/kitty/CmdShell.groovy
(original)
+++ incubator/kitty/trunk/src/main/groovy/org/apache/kitty/CmdShell.groovy Sun
Mar 11 00:36:04 2012
@@ -23,6 +23,8 @@ import org.apache.kitty.utils.Constants
import org.apache.kitty.command.Help
import org.apache.kitty.command.Connect
import org.apache.kitty.command.Disconnect
+import org.apache.kitty.command.SetDomain
+import org.apache.kitty.command.Domains
class CmdShell {
Client client
@@ -62,7 +64,7 @@ class CmdShell {
inputHandler(input)
}
catch (Exception e) {
- println e.getMessage()
+ ioDevice.write(e.getMessage())
}
if (["exit", "quit"].contains(input.tokenize().get(0)))
@@ -209,7 +211,7 @@ class CmdShell {
}
void cmdLs() {
- if (remote) {
+ if (client.remote) {
client.ls()
}
else {
@@ -218,14 +220,12 @@ class CmdShell {
}
void cmdDomains() {
- def domains = getClient().domains()
- if (domains) {
- domains.eachWithIndex() { obj, i -> ioDevice.write " ${i}: ${obj}"
}
- }
+ Command domains = new Domains(ioDevice)
+ domains.execute(client, null)
}
void cmdCd(String path) {
- if (remote) {
+ if (client.remote) {
client.cd(path)
}
else {
@@ -270,12 +270,8 @@ class CmdShell {
}
}
- void cmdSetDomain(def domain) {
- if (remote) {
- client.domain = domain
- }
- else {
- ioDevice.write Constants.ERROR_NOT_CONNECTED
- }
+ void cmdSetDomain(String domain) {
+ Command setDomain = new SetDomain(ioDevice)
+ setDomain.execute(client, domain)
}
}
Added:
incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/Domains.groovy
URL:
http://svn.apache.org/viewvc/incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/Domains.groovy?rev=1299316&view=auto
==============================================================================
---
incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/Domains.groovy
(added)
+++
incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/Domains.groovy
Sun Mar 11 00:36:04 2012
@@ -0,0 +1,21 @@
+package org.apache.kitty.command
+
+import org.apache.kitty.Command
+import org.apache.kitty.IODevice
+import org.apache.kitty.utils.Constants
+
+class Domains implements Command {
+ IODevice ioDevice
+
+ Domains(IODevice ioDevice) {
+ this.ioDevice = ioDevice
+ }
+
+ @Override
+ void execute(org.apache.kitty.client.Client client, String... args) {
+ def domains = client.domains()
+ if (domains) {
+ domains.eachWithIndex() { obj, i -> ioDevice.write " ${i}: ${obj}"
}
+ }
+ }
+}
Added:
incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/SetDomain.groovy
URL:
http://svn.apache.org/viewvc/incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/SetDomain.groovy?rev=1299316&view=auto
==============================================================================
---
incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/SetDomain.groovy
(added)
+++
incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/SetDomain.groovy
Sun Mar 11 00:36:04 2012
@@ -0,0 +1,24 @@
+package org.apache.kitty.command
+
+import org.apache.kitty.Command
+import org.apache.kitty.IODevice
+import org.apache.kitty.utils.Constants
+
+class SetDomain implements Command {
+ IODevice ioDevice
+
+ SetDomain(IODevice ioDevice) {
+ this.ioDevice = ioDevice
+ }
+
+ @Override
+ void execute(org.apache.kitty.client.Client client, String... args) {
+ String domain = args[0]
+ if (client.remote) {
+ client.domain = domain
+ }
+ else {
+ ioDevice.write Constants.ERROR_NOT_CONNECTED
+ }
+ }
+}