Commands: build

These are the commands you run while changing code: compile it, run it, format it, pack it, or throw the outputs away.

histos.cli.Help.render
def render(words: List[String]): Either[HelpError, String] =
    val key = words.map(_.trim).filter(_.nonEmpty).mkString(" ")
    if key.isEmpty then Right(grouped)
    else
      family(key) match
        case Some(text) => Right(text)
        case None       => Left(HelpError.Unknown(key))

compile

histos compile compiles every module. Name projects to compile those and their compilation prerequisites. --platform jvm,js or repeated --platform flags select platforms. --scala 2.13, --scala 3, or a full version such as --scala 3.8.1 selects Scala versions the same way. Whole-build selection keeps matching cells; named modules refuse a platform or a Scala token they do not support, and a series that matches two versions. --tests also compiles test sources. It does not run suites and it does not link. --verbose prints each compiler phase.

histos.ScalaSelection.require
  /** A named module. Each token matches exactly one declared version. */
  def require(module: ProjectName, declared: List[ScalaVersion]): Either[SelectionError, List[ScalaVersion]] =
    this match
      case All               => Right(declared.distinct)
      case Only(first, rest) =>
        ScalaSelection
          .distinctTokens(first :: rest)
          .foldLeft[Either[SelectionError, List[ScalaVersion]]](Right(Nil)): (acc, token) =>
            acc.flatMap: found =>
              declared.filter(ScalaSelection.matches(token, _)).distinct match
                case Nil       => Left(SelectionError.UnsupportedScala(module, token))
                case List(one) => Right(if found.contains(one) then found else found :+ one)
                case many      => Left(SelectionError.AmbiguousScala(module, token, many))

run

histos run <name> runs a module main. It starts one process: one platform and one Scala version. --platform jvm, js, or native selects exactly one supported platform. Without it, the module's runPlatform default wins, then its sole platform. An ambiguous module requires the flag. --scala selects one series or one full version. Omission uses the module's only version, and two declared versions require the flag. A series that matches two versions, or a comma list, is refused before anything starts. Positional platform tokens are not accepted. --main <class> chooses among multiple mains.

Everything after -- is passed to the program, including tokens that look like Histos flags: histos run app --platform jvm --main demo.Main -- --port 8080. The child inherits the caller's environment and working directory. inspect, versions, and doc are built-in run names: they describe the graph, print the catalog, and write scaladoc.

A module's jvmOptions(JvmOptions(...)) configures child JVM run and test processes, not the Histos daemon or program arguments. Use JvmFlag for VM flags and SystemProperty for properties; provider properties also reach test children. A second jvmOptions replaces the first.

{
  import histos.*

  val options = JvmOptions(
    flags = List(JvmFlag("-Xmx2g")),
    properties = List(SystemProperty("demo.mode=local")),
  )
  val app = module("app", Platform.Jvm)(scala"3.8.1").jvmOptions(options)
  (app.name, options.arguments)
}
(app,List(-Xmx2g, -Ddemo.mode=local))

clean

histos clean deletes the outputs of the named projects, or of every module. --full also forgets this repository in the content store, so the next compile cannot reuse a stored result. --full does not take a project name. It is the whole repo.

A production JavaScript file

A Scala.js link is fast by default: the optimizer stays off, and the script is what the linker wrote. The production file is the splice module, which is sbt-splice without sbt. Splice.fast bundles the linker's own imports. Splice.full is that bundle, minified. Splice.closure runs Closure advanced on the Scala.js output and does not shake mapped libraries. Each one fetches a pinned esbuild when it needs one. There is no npm and no package.json.

JsOptimize.Full is Splice.full with no mapped libraries: one classic script. Name libraries when the linker still says import "preact".

The effective optimization is task override, then module jsOptimize, then the locked tool default. An omitted TaskDep.Link mode inherits that cascade. Module run uses the same module/tool choice, so a module declared Full does not silently run Fast. Optimization and module kind are independent settings. Fast and Full use distinct link identities and output directories; a cached Fast script cannot satisfy a Full request. Linking may reuse matching products even when the enclosing Open task's effects must rerun.

histos.JsOptimize.token
def token: String = this match
    case Fast => "fast"
    case Full => "full"

fmt

histos fmt formats sources with the scalafmt version the build locked. Name projects, or pass --file <path> for specific files. --check reports what would change and writes nothing. CI runs scala-cli fmt --check before it installs a toolchain, using the same .scalafmt.conf.

assembly

histos assembly <module> packs each named assembly module into one file and prints the path. The module has to be declared as an assembly in the build. The command does not invent a jar for a library module.