karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject [3/4] git commit: [KARAF-413] Add a file or uri completer for cat command
Date Mon, 19 May 2014 07:19:54 GMT
[KARAF-413] Add a file or uri completer for cat command


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/17c4526f
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/17c4526f
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/17c4526f

Branch: refs/heads/master
Commit: 17c4526f17c8f326f1ce62418aad37fc06c85e5c
Parents: f9a03a3
Author: Guillaume Nodet <gnodet@gmail.com>
Authored: Fri May 16 10:43:25 2014 +0200
Committer: Guillaume Nodet <gnodet@gmail.com>
Committed: Mon May 19 09:19:09 2014 +0200

----------------------------------------------------------------------
 .../karaf/shell/commands/impl/CatAction.java    |  3 +++
 .../shell/impl/console/ConsoleSessionImpl.java  |  2 ++
 .../support/completers/FileOrUriCompleter.java  | 27 ++++++++++++++++++++
 3 files changed, 32 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/17c4526f/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/CatAction.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/CatAction.java
b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/CatAction.java
index 41ec0a6..0471c56 100644
--- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/CatAction.java
+++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/CatAction.java
@@ -31,8 +31,10 @@ import java.util.List;
 import org.apache.karaf.shell.api.action.Action;
 import org.apache.karaf.shell.api.action.Argument;
 import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Completion;
 import org.apache.karaf.shell.api.action.Option;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.support.completers.FileOrUriCompleter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -52,6 +54,7 @@ public class CatAction implements Action {
     private boolean stdin;
 
     @Argument(index = 0, name = "paths or urls", description = "A list of file paths or urls
to display separated by whitespace (use - for STDIN)", required = false, multiValued = true)
+    @Completion(FileOrUriCompleter.class)
     private List<String> paths;
 
     @Override

http://git-wip-us.apache.org/repos/asf/karaf/blob/17c4526f/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
----------------------------------------------------------------------
diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
index dbfc59a..275cbc1 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/ConsoleSessionImpl.java
@@ -55,6 +55,7 @@ import org.apache.karaf.shell.api.console.SessionFactory;
 import org.apache.karaf.shell.api.console.Terminal;
 import org.apache.karaf.shell.support.ShellUtil;
 import org.apache.karaf.shell.support.completers.FileCompleter;
+import org.apache.karaf.shell.support.completers.FileOrUriCompleter;
 import org.apache.karaf.shell.support.completers.UriCompleter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -154,6 +155,7 @@ public class ConsoleSessionImpl implements Session {
         registry.register(new CommandNamesCompleter());
         registry.register(new FileCompleter());
         registry.register(new UriCompleter());
+        registry.register(new FileOrUriCompleter());
 
         // Session
         session = processor.createSession(in != null ? console : null, out, err);

http://git-wip-us.apache.org/repos/asf/karaf/blob/17c4526f/shell/core/src/main/java/org/apache/karaf/shell/support/completers/FileOrUriCompleter.java
----------------------------------------------------------------------
diff --git a/shell/core/src/main/java/org/apache/karaf/shell/support/completers/FileOrUriCompleter.java
b/shell/core/src/main/java/org/apache/karaf/shell/support/completers/FileOrUriCompleter.java
new file mode 100644
index 0000000..4ba45b0
--- /dev/null
+++ b/shell/core/src/main/java/org/apache/karaf/shell/support/completers/FileOrUriCompleter.java
@@ -0,0 +1,27 @@
+/*
+ * 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.karaf.shell.support.completers;
+
+import java.util.Arrays;
+
+public class FileOrUriCompleter extends AggregateCompleter {
+
+    public FileOrUriCompleter() {
+        super(Arrays.asList(new FileCompleter(), new UriCompleter()));
+    }
+
+}


Mime
View raw message