You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by np...@apache.org on 2018/09/12 07:11:05 UTC
[sling-org-apache-sling-pipes] branch master updated: SLING-7678
add | wiring to execute
This is an automated email from the ASF dual-hosted git repository.
npeltier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-pipes.git
The following commit(s) were added to refs/heads/master by this push:
new b27eba8 SLING-7678 add | wiring to execute
b27eba8 is described below
commit b27eba88e5008dc0393465f8beec2cd191c63f4d
Author: Nicolas Peltier <pe...@gmail.com>
AuthorDate: Wed Sep 12 09:10:05 2018 +0200
SLING-7678 add | wiring to execute
---
src/main/java/org/apache/sling/pipes/internal/GogoCommands.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/sling/pipes/internal/GogoCommands.java b/src/main/java/org/apache/sling/pipes/internal/GogoCommands.java
index 7c225c2..b03c7d9 100644
--- a/src/main/java/org/apache/sling/pipes/internal/GogoCommands.java
+++ b/src/main/java/org/apache/sling/pipes/internal/GogoCommands.java
@@ -16,6 +16,7 @@
*/
package org.apache.sling.pipes.internal;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
@@ -30,6 +31,7 @@ import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.StringReader;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -55,11 +57,13 @@ public class GogoCommands {
protected final static String SEPARATOR = "/";
protected final static String PARAMS = "@";
+ protected final static String INPUT = "-";
protected final static String KEY_VALUE_SEP = "=";
protected final static String KEY_NAME = "name";
protected final static String KEY_PATH = "path";
protected final static String KEY_EXPR = "expr";
+
@Reference
ResourceResolverFactory factory;
@@ -101,8 +105,9 @@ public class GogoCommands {
* @throws Exception in case anything went wrong
*/
public void execute(String path, String... options) throws Exception {
+ String computedPath = INPUT.equals(path) ? IOUtils.toString(System.in).trim() : path;
try (ResourceResolver resolver = factory.getServiceResourceResolver(plumber.getServiceUser())) {
- System.out.println(executeInternal(resolver, path, options));
+ System.out.println(executeInternal(resolver, computedPath, options));
} catch(Exception e){
log.error("Unable to execute {}", path, e);
throw(e);
@@ -140,7 +145,7 @@ public class GogoCommands {
* help command handler
*/
public void help(){
- System.out.format("Available commands are \n- execute <path> <options>(execute a pipe already built at a given path)" +
+ System.out.format("\nSling Pipes Help\nAvailable commands are \n\n- execute <path> <options>(execute a pipe already built at a given path), if path is '-' then previous pipe token is used," +
"\n- build (build pipe as configured in arguments)" +
"\n- run (run pipe as configured in arguments)" +
"\n- help (print this help)" +