code: static Path create(final Iterable<String> commands, final boolean batch, final boolean failOnError) throws IOException {
          final Path tempScript = Files.createTempFile("cli-scrpts", ".cli");
          try (BufferedWriter writer = Files.newBufferedWriter(tempScript, StandardCharsets.UTF_8)) {
              if (batch) {
                  writer.write("batch");
                  writer.newLine();
              }
  
              boolean inTry = false;
  
              for (String cmd : commands) {
                  if (failOnError) {
                      writeCommand(writer, cmd);
                  } else {
                      if ("try".equals(cmd.trim())) {
                          inTry = true;
                      }
                      if (inTry) {
                          writeCommand(writer, cmd);
                      } else {
                          writeCommandInTry(writer, cmd);
                      }
                      if ("end-try".equals(cmd.trim())) {
                          inTry = false;
                      }
                  }
              }
  
              if (batch) {
                  writer.write("run-batch");
                  writer.newLine();
              }
          }
          return tempScript;
      }
docs: Creates a script file for the commands. If {@code failOnError} is {@code false} the command will be wrapped in a
  {@code try-catch} command.
  
  @param commands    the commands to write to the scripts
  @param batch       {@code true} if the batch command should be added
  @param failOnError {@code false} to wrap commands in a {@code try-catch}
  
  @return the script file
  
  @throws IOException if an error occurs creating the script file