I'm building a command Line application with java picocli that basically wraps npm, maven, git, azure, and some utility commands I want to have pre-done. My issue is when for example npm install is run, it prints a whole array of stuff like warning about all the stuff it installed and logs as well as that progress bar that writes a load of stuff. Is there any way I can emulate that to my app? Now I have this to run a process:
protected static void run(String dir, String... strings) {
try {
var process = new ProcessBuilder(strings).directory(new File(dir)).start();
process.waitFor();
write(process.getInputStream(), System.out);
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
private static void write(InputStream stream, PrintStream out) throws IOException {
String line = null;
StringBuffer buffer = new StringBuffer();
var reader = new BufferedReader(new InputStreamReader(stream));
while ((line = reader.readLine()) != null)
buffer.append(line);
out.println(buffer.toString());
}
Is there any way I can get those other prints as well as the progress bar? Right now I just get the final like 5 lines that say the number of vulnerabilities after installing?