package com.github.sormuras.bach;

import java.io.PrintStream;

/** Java Shell Builder. */
public final class Bach implements Print {

  /**
   * Returns a shell builder initialized with default components.
   *
   * @return a new instance of {@code Bach} initialized with default components
   */
  public static Bach ofSystem() {
    return new Bach(System.out);
  }

  /**
   * Returns the version of Bach.
   *
   * @return the version as a string or {@code "?"} if the version is unknown at runtime
   */
  public static String version() {
    var descriptor = Bach.class.getModule().getDescriptor();
    if (descriptor == null) return "?";
    return descriptor.version().map(Object::toString).orElse("?");
  }

  /** A print stream for normal messages. */
  private final PrintStream printer;

  /**
   * Initialize default constructor.
   *
   * @param printer the print stream for normal messages
   */
  public Bach(PrintStream printer) {
    this.printer = printer;
  }

  /**
   * Returns the print stream for normal messages.
   *
   * @return the print stream for normal messages
   */
  public PrintStream printer() {
    return printer;
  }
}

@@ -39,27 +39,148 @@
 ort 
-java.io.PrintStream
+com.github.sormuras.bach.internal.Functions;%0Aimport java.io.PrintStream;%0Aimport java.net.http.HttpClient;%0Aimport java.util.function.Supplier
 ;%0A%0A/
@@ -239,16 +239,22 @@
 plements
+ Http,
  Print %7B
@@ -482,16 +482,52 @@
 stem.out
+, Functions.memoize(Http::newClient)
 );%0A  %7D%0A%0A
@@ -957,16 +957,112 @@
 inter;%0A%0A
+  /** A supplier of a http client. */%0A  private final Supplier%3CHttpClient%3E httpClientSupplier;%0A%0A
   /**%0A  
@@ -1201,162 +1201,230 @@
 nter
-) %7B%0A    this.printer = printer;%0A  %7D%0A%0A  /**%0A   * Returns the print stream for normal messages.%0A   *
+, Supplier%3CHttpClient%3E httpClientSupplier) %7B%0A    this.printer = printer;%0A    this.httpClientSupplier = httpClientSupplier;%0A  %7D%0A%0A  @Override%0A  public HttpClient http() %7B
 %0A   
-* @
+ 
 return 
-the print stream for normal messages%0A   */
+httpClientSupplier.get();%0A  %7D%0A%0A  @Override
 %0A  p

Implement Http API