Uploaded image for project: 'Aesh'
  1. Aesh
  2. AESH-223

Support Object pipe

XMLWordPrintable

    • Icon: Feature Request Feature Request
    • Resolution: Won't Do
    • Icon: Major Major
    • 0.57
    • 0.51
    • main
    • None

      If a Aesh command could return some form of Object Result instead of just a simple int status we could allow for some more advanced pipe options between Commands.

      public interface Formatter<T> {
        void format(T, Output)
      }
      public interface Result<T, Formatter<T>> {}
      

      When the user pipe two commands together, Aesh could now try to match the Output with the Input of the next Command.

      Let's say we have the following:

      public class ListDependenciesCommand {
        Result<Set<MavenDependency>>, Formatter<Set<MavenDependency>> execute(CommandInvocation) {
          .. do pom magic, return Set<MavenDependency>
        }
      }
      
      public class GrepCommand {
        @OptionList
        private List<Object> pipeInput;
      
        @Option
        private String arguments;
      
        Result<Set<Object>>, Formatter<Set<Object>> execute(CommandInvocation) {
          .. grep based on el expression passed in by arguments on each Object in pipeinput and return Set<Object>
        }
      }
      

      Now you could do Object value grepping, not only 'what was printed' grepping.

      list-dependencies pom.xml | grep "$groupId == 'org.arquillian'" | sort "$version" | add-dependencies --target ../some-other/pom.xml
      

      If the command is not executed in 'pipe mode', the Results Formatter would simply be called instead.

              spederse@redhat.com Stale Pedersen
              aslak@redhat.com Aslak Knutsen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: