diff --git a/res/build.id b/res/build.id index 9c54547..75c2bf7 100644 --- a/res/build.id +++ b/res/build.id @@ -1 +1 @@ -1639 +1668 diff --git a/src/cli/actions.scala b/src/cli/actions.scala index 2877bab..8f1443d 100644 --- a/src/cli/actions.scala +++ b/src/cli/actions.scala @@ -133,6 +133,7 @@ object actions: ExitStatus.Ok object universe: + def show()(using Internet, WorkingDirectory, Monitor, Log[Display], FrontEnd, Stdio): ExitStatus raises UserError = given (UserError fixes PathError) = accede given (UserError fixes ConcurrencyError) = accede diff --git a/src/cli/cli.scala b/src/cli/cli.scala index 2132a3d..3b365e9 100644 --- a/src/cli/cli.scala +++ b/src/cli/cli.scala @@ -21,6 +21,7 @@ import anticipation.* import aviation.* import contingency.* import digression.* +import cellulose.*, codlPrinters.standard import escapade.* import escritoire.*, tableStyles.minimal, insufficientSpaceHandling.ignore import ethereal.*, daemonConfig.supportStderr @@ -30,6 +31,7 @@ import fulminate.* import galilei.*, filesystemInterfaces.galileiApi, filesystemOptions.dereferenceSymlinks import gastronomy.* import gossamer.* +import octogenarian.* import guillotine.* import hallucination.* import hellenism.*, classloaders.threadContext @@ -78,6 +80,8 @@ object cli: def Generation(using Errant[NumberError]) = Flag[Int](t"generation", false, List('g'), t"Use universe generation number") + + val Stream = Flag[Text](t"stream", false, List('s'), t"Which stream to publish to") val About = Subcommand(t"about", e"About Fury") val Build = Subcommand(t"build", e"Start a new build (default)") @@ -243,13 +247,33 @@ def main(): Unit = Out.println(t"Project has not been specified") ExitStatus.Fail(1) - case project :: _ => - safely: - project.suggest(Workspace().build.projects.map(_.suggestion)) + case projectId :: _ => + val workspace = safely(Workspace()) + + workspace.let: workspace => + projectId.suggest(workspace.build.projects.map(_.suggestion)) execute: - Out.println(t"Not yet publishing ${project()}") - ExitStatus.Fail(1) + import filesystemOptions.{doNotCreateNonexistent, dereferenceSymlinks} + given (UserError fixes WorkspaceError) = error => UserError(error.message) + given (UserError fixes GitError) = error => UserError(error.message) + given (UserError fixes IoError) = error => UserError(error.message) + given (UserError fixes ExecError) = error => UserError(error.message) + given (UserError fixes PathError) = error => UserError(error.message) + given (UserError fixes ReleaseError) = error => UserError(error.message) + given (UserError fixes InvalidRefError) = error => UserError(error.message) + val workspace = Workspace() + workspace.build.projects.where(_.id.show == projectId()).let: project => + val directory = safely(workingDirectory).or: + abort(UserError(msg"The working directory could not be determined.")) + val repo = GitRepo(directory) + val release = project.release(StreamId(t"whatever"), 30, Snapshot(url"https://example.com/", repo.status(), Unset)) + Out.println(release.codl.show) + ExitStatus.Fail(1) + .or: + Out.println(t"Project ${projectId()} is not defined in this workspace") + ExitStatus.Fail(2) + case _ => execute: Out.println(t"Unknown command") diff --git a/src/model/licenses.scala b/src/model/licenses.scala index 984cdce..072540a 100644 --- a/src/model/licenses.scala +++ b/src/model/licenses.scala @@ -25,7 +25,7 @@ enum LicenseGroup: case Afl, Apache, Artistic, Bsl, Bsd, Cc, Wtfpl, Ecl, Epl, Eupl, Agpl, Gpl, Lgpl, Isc, Lppl, Ms, Mit, Mpl, Osl, PostgreSql, Ofl, Ncsa, Unlicense, Zlib -enum License(name: InlineMd, id: LicenseId, group: LicenseGroup): +enum License(val name: InlineMd, val id: LicenseId, val group: LicenseGroup): case Afl3 extends License(md"Academic Free License v3.0", LicenseId.unsafe(t"afl-3.0"), LicenseGroup.Afl) diff --git a/src/model/model.scala b/src/model/model.scala index 8d9cc1b..2be3226 100644 --- a/src/model/model.scala +++ b/src/model/model.scala @@ -164,6 +164,33 @@ derives Debug, CodlEncoder: def definition(workspace: Workspace): Definition = Definition(name, description, website, license, keywords, workspace) + def release(stream: StreamId, lifetime: Int, snapshot: Snapshot): Release raises ReleaseError = + given Timezone = tz"Etc/UTC" + + Release + (id = id, + stream = stream, + name = name, + website = website, + description = description, + license = license.or: + raise(ReleaseError(ReleaseError.Reason.NoLicense))(License.Apache2.id), + date = today(), + lifetime = lifetime, + repo = snapshot, + packages = Nil, + keywords = keywords) + +object ReleaseError: + enum Reason: + case NoLicense + + given Communicable[Reason] = + case Reason.NoLicense => msg"the license has not been specified" + +case class ReleaseError(reason: ReleaseError.Reason) +extends Error(msg"The project is not ready for release because $reason") + case class Assist(target: Target, module: GoalId) derives Debug, CodlEncoder object Basis extends RefType(t"basis"):