diff --git a/res/build.id b/res/build.id index d878b32..0a75ff7 100644 --- a/res/build.id +++ b/res/build.id @@ -1 +1 @@ -1100 +1110 diff --git a/src/cli/actions.scala b/src/cli/actions.scala index 86929af..161c1e9 100644 --- a/src/cli/actions.scala +++ b/src/cli/actions.scala @@ -51,7 +51,7 @@ case class InitError(initMessage: Message) extends Error(initMessage) object actions: object install: - def interactive(force: Boolean, noTabCompletions: Boolean) + def installInteractive(force: Boolean, noTabCompletions: Boolean) (using DaemonService[?], Log[Display], SystemProperties, @@ -59,7 +59,7 @@ object actions: WorkingDirectory, HomeDirectory, Effectful, - FrontEnd, + CliFrontEnd, Terminal, Stdio) : ExitStatus raises UserError = @@ -73,10 +73,11 @@ object actions: if directories.length <= 1 then Installer.install(force) else info(e"$Italic(Please choose an install location.)") - val menu = SelectMenu(directories, directories.head) - val (target, events2) = menu.ask(terminal.events.stream) - info(e"Installing to $target/${service.scriptName}") - info(Installer.install(force = true, target).communicate) + + interactive: + SelectMenu(directories, directories.head).ask: target => + info(e"Installing to $target/${service.scriptName}") + info(Installer.install(force = true, target).communicate) if !noTabCompletions then Out.println(TabCompletions.install(force = true).communicate) @@ -153,8 +154,18 @@ object actions: ExitStatus.Ok object build: - def initialize(directory: Path)(using FrontEnd): ExitStatus raises UserError = + def initialize(directory: Path)(using CliFrontEnd): ExitStatus raises UserError = + given (UserError fixes DismissError) = accede + if (directory / p".fury").exists() then abort(UserError(msg"A build already exists in this directory")) info(msg"Creating a new build in $directory") + + interactive: + info(e"$Italic(Please enter the project name:)") + LineEditor(t"hello-world", 11).ask: choice => + info(e"You chose $Bold($choice)") + //val (name, events2) = LineEditor(t"hello-world").ask(events) + //info(e"Project has the name $name") + ExitStatus.Ok def run(target: Target, watch: Boolean, force: Boolean) diff --git a/src/cli/cli.scala b/src/cli/cli.scala index 0f28d19..e57996a 100644 --- a/src/cli/cli.scala +++ b/src/cli/cli.scala @@ -138,20 +138,19 @@ def main(): Unit = execute: frontEnd: - if interactive then actions.install.interactive(force, noTabCompletions) + if interactive then actions.install.installInteractive(force, noTabCompletions) else actions.install.batch(force, noTabCompletions) service.shutdown() ExitStatus.Ok case Init() :: Nil => - val dir: Optional[Path] = safely(Dir()).or(safely(workingDirectory)) - val discover = Discover() execute: frontEnd: - dir.let(actions.build.initialize(_)).or: + val directory = safely(workingDirectory).or: abort(UserError(msg"The working directory could not be determined.")) + actions.build.initialize(directory) case Config() :: Nil => execute: diff --git a/src/cli/clifrontend.scala b/src/cli/clifrontend.scala index 8f519fe..e0afb93 100644 --- a/src/cli/clifrontend.scala +++ b/src/cli/clifrontend.scala @@ -29,6 +29,7 @@ import escapade.* import anticipation.* import iridescence.* import gossamer.* +import profanity.* import rudiments.* import spectacular.* import quantitative.* @@ -52,7 +53,13 @@ def frontEnd[ResultType](lambda: CliFrontEnd ?=> Terminal ?=> ResultType)(using safely(frontEnd.render(last = true)) FrontEnd.unregister(frontEnd) -class CliFrontEnd()(using terminal: Terminal) extends FrontEnd: +def interactive[ResultType](using frontEnd: CliFrontEnd) + (block: Stdio ?=> Interactivity[TerminalEvent] ?=> ResultType) + : ResultType = + block(using frontEnd.terminal.stdio)(using frontEnd.terminal) + +class CliFrontEnd()(using Terminal) extends FrontEnd: + def terminal = summon[Terminal] given stdio: Stdio = terminal.stdio private var dag: Optional[Dag[Target]] = Unset private var diagram: Optional[DagDiagram[Target]] = Unset diff --git a/src/model/model.scala b/src/model/model.scala index 098e0b4..6af2268 100644 --- a/src/model/model.scala +++ b/src/model/model.scala @@ -201,12 +201,17 @@ case class ManifestEntry(key: Text, value: Text) derives Debug, CodlEncoder object Container: given relabelling: CodlRelabelling[Container] = () => - Map(t"copies" -> t"copy") + Map(t"insertions" -> t"copy") case class Insertion(source: WorkPath, destination: WorkPath) derives Debug, CodlEncoder case class Extraction(source: WorkPath, destination: WorkPath) derives Debug, CodlEncoder -case class Container(id: GoalId, path: WorkPath, insertions: List[Insertion], extractions: List[Extraction]) +case class Container + (id: GoalId, + dockerfile: WorkPath, + root: WorkPath, + insertions: List[Insertion], + extractions: List[Extraction]) derives Debug, CodlEncoder object Exec: