incubator-kitty-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anovar...@apache.org
Subject svn commit: r1299320 - in /incubator/kitty/trunk/src/main/groovy/org/apache/kitty: CmdShell.groovy command/Cd.groovy command/Connect.groovy command/GetAttribute.groovy command/Invoke.groovy command/SetAttribute.groovy
Date Sun, 11 Mar 2012 01:28:52 GMT
Author: anovarini
Date: Sun Mar 11 01:28:52 2012
New Revision: 1299320

URL: http://svn.apache.org/viewvc?rev=1299320&view=rev
Log:
Extracted last commands

Added:
    incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/Cd.groovy
    incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/GetAttribute.groovy
    incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/Invoke.groovy
    incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/SetAttribute.groovy
Modified:
    incubator/kitty/trunk/src/main/groovy/org/apache/kitty/CmdShell.groovy
    incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/Connect.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=1299320&r1=1299319&r2=1299320&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 01:28:52
2012
@@ -26,6 +26,10 @@ import org.apache.kitty.command.Domains
 import org.apache.kitty.command.Exit
 import org.apache.kitty.command.Ls
 import org.apache.kitty.command.Pwd
+import org.apache.kitty.command.Invoke
+import org.apache.kitty.command.SetAttribute
+import org.apache.kitty.command.GetAttribute
+import org.apache.kitty.command.Cd
 
 class CmdShell {
 	Client client
@@ -58,9 +62,6 @@ class CmdShell {
 		LOOP: while (true) {
 			def input = ioDevice.read()
 
-			if (input.length() == 0)
-				continue
-
             try {
 				inputHandler(input)
 			}
@@ -210,48 +211,32 @@ class CmdShell {
 
 	void cmdLs() {
         Command ls = new Ls(ioDevice)
-        ls.execute(client, null)
+        ls.execute client, null
 	}
 
 	void cmdDomains() {
         Command domains = new Domains(ioDevice)
-        domains.execute(client, null)
+        domains.execute client, null
 	}
 
 	void cmdCd(String path) {
-		if (client.remote) {
-			client.cd(path)
-		}
-		else {
-            ioDevice.write Constants.ERROR_NOT_CONNECTED
-		}
+        Command cd = new Cd(ioDevice)
+        cd.execute client, path
 	}
 
 	void cmdGet(def attr) {
-		if (remote) {
-			client.get(attr)
-		}
-		else {
-            ioDevice.write Constants.ERROR_NOT_CONNECTED
-		}
+        Command getAttribute = new GetAttribute(ioDevice)
+        getAttribute.execute(client, attr)
 	}
 
 	void cmdSet(def attr, def val) {
-		if (remote) {
-			client.set(attr, val)
-		}
-		else {
-            ioDevice.write Constants.ERROR_NOT_CONNECTED
-		}
+        Command setAttribute = new SetAttribute(ioDevice)
+        setAttribute.execute(client, attr, val)
 	}
 
 	void cmdInvoke(def op, def params) {
-		if (remote) {
-			client.invoke(op, params)
-		}
-		else {
-            ioDevice.write Constants.ERROR_NOT_CONNECTED
-		}
+        Command invoke = new Invoke(ioDevice)
+        invoke.execute client, op, params
 	}
 
 	void cmdPwd() {

Added: incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/Cd.groovy
URL: http://svn.apache.org/viewvc/incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/Cd.groovy?rev=1299320&view=auto
==============================================================================
--- incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/Cd.groovy (added)
+++ incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/Cd.groovy Sun Mar 11 01:28:52
2012
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kitty.command
+
+import org.apache.kitty.IODevice
+import org.apache.kitty.Command
+import org.apache.kitty.client.Client
+import org.apache.kitty.utils.Constants
+
+class Cd implements Command {
+    IODevice ioDevice
+
+    Cd(IODevice ioDevice) {
+        this.ioDevice = ioDevice
+    }
+
+    @Override
+    void execute(Client client, String... args) {
+        if (client.remote) {
+            client.cd(args[0])
+        }
+        else {
+            ioDevice.write Constants.ERROR_NOT_CONNECTED
+        }
+    }
+}

Modified: incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/Connect.groovy
URL: http://svn.apache.org/viewvc/incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/Connect.groovy?rev=1299320&r1=1299319&r2=1299320&view=diff
==============================================================================
--- incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/Connect.groovy (original)
+++ incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/Connect.groovy Sun Mar
11 01:28:52 2012
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.kitty.command
 
 import org.apache.kitty.client.Client

Added: incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/GetAttribute.groovy
URL: http://svn.apache.org/viewvc/incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/GetAttribute.groovy?rev=1299320&view=auto
==============================================================================
--- incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/GetAttribute.groovy (added)
+++ incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/GetAttribute.groovy Sun
Mar 11 01:28:52 2012
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kitty.command
+
+import org.apache.kitty.IODevice
+import org.apache.kitty.Command
+import org.apache.kitty.utils.Constants
+import org.apache.kitty.client.Client
+
+class GetAttribute implements Command {
+    IODevice ioDevice
+
+    GetAttribute(IODevice ioDevice) {
+        this.ioDevice = ioDevice
+    }
+
+    @Override
+    void execute(Client client, String... args) {
+        if (client.remote) {
+            client.get(args[0])
+        }
+        else {
+            ioDevice.write Constants.ERROR_NOT_CONNECTED
+        }
+    }
+}

Added: incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/Invoke.groovy
URL: http://svn.apache.org/viewvc/incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/Invoke.groovy?rev=1299320&view=auto
==============================================================================
--- incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/Invoke.groovy (added)
+++ incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/Invoke.groovy Sun Mar 11
01:28:52 2012
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kitty.command
+
+import org.apache.kitty.IODevice
+import org.apache.kitty.Command
+import org.apache.kitty.client.Client
+import org.apache.kitty.utils.Constants
+
+class Invoke implements Command {
+    IODevice ioDevice
+
+    Invoke(IODevice ioDevice) {
+        this.ioDevice = ioDevice
+    }
+
+    @Override
+    void execute(Client client, String... args) {
+        if (client.remote) {
+            String operation = args[0]
+            String params = args.tail()
+            client.invoke(operation, params)
+        }
+        else {
+            ioDevice.write Constants.ERROR_NOT_CONNECTED
+        }
+    }
+}

Added: incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/SetAttribute.groovy
URL: http://svn.apache.org/viewvc/incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/SetAttribute.groovy?rev=1299320&view=auto
==============================================================================
--- incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/SetAttribute.groovy (added)
+++ incubator/kitty/trunk/src/main/groovy/org/apache/kitty/command/SetAttribute.groovy Sun
Mar 11 01:28:52 2012
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kitty.command
+
+import org.apache.kitty.IODevice
+import org.apache.kitty.Command
+import org.apache.kitty.utils.Constants
+import org.apache.kitty.client.Client
+
+class SetAttribute implements Command {
+    IODevice ioDevice
+
+    SetAttribute(IODevice ioDevice) {
+        this.ioDevice = ioDevice
+    }
+
+    @Override
+    void execute(Client client, String... args) {
+        if (client.remote) {
+            String attr = args[0]
+            String val = args[1]
+            client.set(attr, val)
+        }
+        else {
+            ioDevice.write Constants.ERROR_NOT_CONNECTED
+        }
+    }
+}



Mime
View raw message