mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-04 22:50:18 +00:00
add aqua run
services support (#551)
This commit is contained in:
parent
98ee1c7083
commit
5bd30c7918
@ -42,12 +42,17 @@ class FuncCompiler[F[_]: Files: AquaIO: Async](
|
||||
func: CliFunc,
|
||||
services: List[JsonService]
|
||||
): ValidatedNec[String, (FuncArrow, List[Service])] =
|
||||
contexts
|
||||
.collectFirstSome(c => c.allFuncs.get(func.name))
|
||||
func.ability
|
||||
.fold(
|
||||
contexts
|
||||
.collectFirstSome(_.allFuncs.get(func.name))
|
||||
)(ab =>
|
||||
contexts.collectFirstSome(_.abilities.get(ab).flatMap(_.allFuncs.get(func.name)))
|
||||
)
|
||||
.map(validNec)
|
||||
.getOrElse(
|
||||
Validated.invalidNec[String, FuncArrow](
|
||||
s"There is no function '${func.name}' or it is not exported. Check the spelling or see https://doc.fluence.dev/aqua-book/language/header#export"
|
||||
s"There is no function '${func.ability.map(_ + ".").getOrElse("")}${func.name}' or it is not exported. Check the spelling or see https://doc.fluence.dev/aqua-book/language/header#export"
|
||||
)
|
||||
)
|
||||
.andThen { func =>
|
||||
@ -62,7 +67,8 @@ class FuncCompiler[F[_]: Files: AquaIO: Async](
|
||||
): ValidatedNec[String, List[Service]] = {
|
||||
services
|
||||
.map(js =>
|
||||
contexts.collectFirstSome(_.services.get(js.name))
|
||||
contexts
|
||||
.collectFirstSome(_.services.get(js.name))
|
||||
.map(sm => (js, sm))
|
||||
.map(validNec)
|
||||
.getOrElse(
|
||||
@ -90,7 +96,10 @@ class FuncCompiler[F[_]: Files: AquaIO: Async](
|
||||
case h :: _ =>
|
||||
Conversions.ts2aqua(jf.result, TypeDefinitionJs(TypeDefinition(h)))
|
||||
case Nil =>
|
||||
Conversions.ts2aqua(jf.result, TypeDefinitionJs(TypeDefinition(NilType)))
|
||||
Conversions.ts2aqua(
|
||||
jf.result,
|
||||
TypeDefinitionJs(TypeDefinition(NilType))
|
||||
)
|
||||
}
|
||||
|
||||
js.Promise.resolve(converted)
|
||||
|
@ -113,7 +113,7 @@ object Plugin {
|
||||
|
||||
def opt[F[_]: Files: Concurrent]: Opts[F[ValidatedNec[String, List[String]]]] = {
|
||||
Opts
|
||||
.options[String]("plugin", "[experimental] Path to a directory with JS plugins", "p", "path")
|
||||
.options[String]("plugin", "[experimental] Path to a directory with JS plugins", "", "path")
|
||||
.map { strs =>
|
||||
strs.toList.map(s => pathToMjsFilesList(s)).sequence.map(_.sequence.map(_.flatten))
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ object ScriptOpts extends Logging {
|
||||
def remove[F[_]: Async]: SubCommandBuilder[F] =
|
||||
SubCommandBuilder.valid[F](
|
||||
"remove",
|
||||
"Remove a service from a remote peer",
|
||||
"Remove a script from a remote peer",
|
||||
(
|
||||
commonScriptOpts,
|
||||
scriptIdOpt
|
||||
|
Loading…
Reference in New Issue
Block a user