First project

Once histos is on your PATH, you can start a project from nothing, or draft one from a build you already have. Both commands write histos.scala, the sources, and a build.properties that pins the Histos that wrote them. The pin is how the next person who clones the directory runs the same toolchain.

A new directory, or this one

histos new <name> creates a directory and writes the project inside it. histos init writes the project into the directory you are already in. Use new when you are starting fresh. Use init when the directory already exists and you want Histos files added to it.

With no extra flags, the command asks you how much to write. You do not have to remember the flags to get a working project.

histos.cli.ScaffoldChoice
/** `new` and `init`. `--bare` wins over `--yes`. `--yes` confirms the full scaffold and the default branch. */
enum ScaffoldChoice

How much to write

--bare writes the build file and the sources, and stops. That is the right choice when you will add CI yourself.

--yes accepts the defaults of the full scaffold, including the branch name CI will use, and does not ask. Use it from a script.

--branch <name> sets that CI branch when you do not want the default.

If you pass neither --bare nor --yes, Histos asks.

histos.cli.ScaffoldChoice.from
def from(bare: Boolean, yes: Boolean): ScaffoldChoice =
    if bare then Bare
    else if yes then Confirmed
    else Prompt

Start from an sbt or zipx build

If the directory already has an sbt build, histos init --from sbt reads build.sbt and drafts histos.scala from it. histos init --from zipx reads project/ZipxVersions.scala from a zipx build. Anything the draft does not know how to map is left as a comment, so you can see what still needs a decision. The draft is a starting point. Read it before you trust it.

histos.scaffold.ImportSource.from
def from(raw: String): Option[ImportSource] =
    raw match
      case "sbt"  => Some(ImportSource.Sbt)
      case "zipx" => Some(ImportSource.Zipx)
      case _      => None

What `new` writes

The generated build is one JVM module, a ZIO dependency, and a main class. The Scala version and the ZIO version are the ones the scaffold writes on the day you run it. They are not a second copy kept in this manual. Open histos.scala after new and you are looking at the file the command wrote.

histos.scaffold.Skeleton
/** The one-module project `histos new` and `histos init` write. The pin is the toolchain that wrote it. `scalaVersion`
  * and `zioVersion` are the versions this repository builds with.
  */
object Skeleton:
  val scalaVersion: String = "3.10.1"
  val zioVersion: String   = "2.1.27"

  val ignoreLines: List[String] = List(".histos/", "out/")

  def create(
      parent: Path,
      raw: String,
      version: String,
      kind: ScaffoldKind = ScaffoldKind.Full,
      shim: Option[Sha256] = None,
  ): IO[SkeletonError, Path] =
    for
      name <- ZIO.fromEither(ProjectName.from(raw)).mapError(_ => SkeletonError.Name(raw))
      dir = parent.resolve(name.value)
      _ <- empty(dir)

…