You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2012/02/08 15:33:42 UTC

svn commit: r1241910 - /karaf/trunk/shell/commands/src/main/java/org/apache/karaf/shell/shell/SleepAction.java

Author: jbonofre
Date: Wed Feb  8 14:33:42 2012
New Revision: 1241910

URL: http://svn.apache.org/viewvc?rev=1241910&view=rev
Log:
[KARAF-1191] Switching back to milliseconds by default in shell:sleep and add the -s (second) option


Conflicts:

	shell/commands/src/main/java/org/apache/karaf/shell/shell/SleepAction.java

Modified:
    karaf/trunk/shell/commands/src/main/java/org/apache/karaf/shell/shell/SleepAction.java

Modified: karaf/trunk/shell/commands/src/main/java/org/apache/karaf/shell/shell/SleepAction.java
URL: http://svn.apache.org/viewvc/karaf/trunk/shell/commands/src/main/java/org/apache/karaf/shell/shell/SleepAction.java?rev=1241910&r1=1241909&r2=1241910&view=diff
==============================================================================
--- karaf/trunk/shell/commands/src/main/java/org/apache/karaf/shell/shell/SleepAction.java (original)
+++ karaf/trunk/shell/commands/src/main/java/org/apache/karaf/shell/shell/SleepAction.java Wed Feb  8 14:33:42 2012
@@ -18,19 +18,28 @@ package org.apache.karaf.shell.shell;
 
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
 import org.apache.karaf.shell.console.AbstractAction;
 
 @Command(scope = "shell", name = "sleep", description = "Sleeps for a bit then wakes up.")
 public class SleepAction extends AbstractAction {
 
-    @Argument(index = 0, name = "duration", description = "The amount of seconds to sleep", required = true, multiValued = false)
+    @Argument(index = 0, name = "duration", description = "The amount of time to sleep. The default time unit is millisecond, use -s option to use second instead.", required = true, multiValued = false)
     private long time = -1;
+    
+    @Option(name = "-s", aliases = { "--second" }, description = "Use a duration time in seconds instead of milliseconds.", required = false, multiValued = false)
+    private boolean second = false;
 
     protected Object doExecute() throws Exception {
-        log.info("Sleeping for {} second(s)", time);
+        if (second) {
+            log.info("Sleeping for {} second(s)", time);
+            time = time * 1000;
+        } else {
+            log.info("Sleeping for {} millisecond(s)", time);
+        }
 
         try {
-            Thread.sleep(time * 1000);
+            Thread.sleep(time);
         }
         catch (InterruptedException ignore) {
             log.debug("Sleep was interrupted... :-(");