Open rj93 opened 4 months ago
Unfortunately this is not yet supported. There's been a recent work in JLine making process input/output easier to handle so hopefully we're able to implement these features.
Forgive my naivety, but why couldn't a simple InputStreamReader
be used to read in from the pipe?
It is fairly safe to assume that when using a pipe a program would be ran in not interactive mode, so could the following potentially be updated to read from System.in
and then parse the commands?
I've got a crude local test and it works with the quickstart example:
public void run(ApplicationArguments args) throws Exception {
shellContext.setInteractionMode(InteractionMode.NONINTERACTIVE);
args = mergePipeAndArgs(args);
List<String> commands = this.commandsFromInputArgs.apply(args);
...
}
private ApplicationArguments mergePipeAndArgs(ApplicationArguments args) {
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
String[] mergedArgs = Stream.concat(Arrays.stream(args.getSourceArgs()), stdin.lines())
.toArray(String[]::new);
return new DefaultApplicationArguments(mergedArgs);
}
Did a bit more playing around with the above and it doesn't play very nice piping file contents to it, for example YAML files get parsed broken because of some post processing
Hi,
I am trying to find out how to pipe to a commands standard input.
Taking the quick start example:
I would like to be able to achieve: