@effect/cli
Advanced tools
Comparing version 0.12.0 to 0.13.0
@@ -5,3 +5,2 @@ /** | ||
import type { Command } from "@effect/cli/Command"; | ||
import type { Console } from "@effect/cli/Console"; | ||
import type { HelpDoc } from "@effect/cli/HelpDoc"; | ||
@@ -26,12 +25,2 @@ import type { Span } from "@effect/cli/HelpDoc/Span"; | ||
* @since 1.0.0 | ||
*/ | ||
export declare namespace CliApp { | ||
/** | ||
* @since 1.0.0 | ||
* @category models | ||
*/ | ||
type Context = Console; | ||
} | ||
/** | ||
* @since 1.0.0 | ||
* @category constructors | ||
@@ -51,5 +40,5 @@ */ | ||
export declare const run: { | ||
<R, E, A>(args: ReadonlyArray<string>, f: (a: A) => Effect<CliApp.Context | R, E, void>): (self: CliApp<A>) => Effect<CliApp.Context | R, E | ValidationError, void>; | ||
<R, E, A>(self: CliApp<A>, args: ReadonlyArray<string>, f: (a: A) => Effect<CliApp.Context | R, E, void>): Effect<CliApp.Context | R, ValidationError | E, void>; | ||
<R, E, A>(args: ReadonlyArray<string>, f: (a: A) => Effect<R, E, void>): (self: CliApp<A>) => Effect<R, E | ValidationError, void>; | ||
<R, E, A>(self: CliApp<A>, args: ReadonlyArray<string>, f: (a: A) => Effect<R, E, void>): Effect<R, ValidationError | E, void>; | ||
}; | ||
//# sourceMappingURL=CliApp.d.ts.map |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.run = exports.make = void 0; | ||
var Console = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/cli/Console")); | ||
var cliConfig = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/cli/internal/cliConfig")); | ||
@@ -19,2 +18,3 @@ var command = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/cli/internal/command")); | ||
var Option = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Option")); | ||
var Console = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Console")); | ||
var Effect = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Effect")); | ||
@@ -47,24 +47,22 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
const runBuiltInMap = { | ||
ShowCompletions: () => Effect.sync(() => { | ||
// case ShowCompletions(index, _) => | ||
// envs.flatMap { envMap => | ||
// val compWords = envMap.collect { | ||
// case (idx, word) if idx.startsWith("COMP_WORD_") => | ||
// (idx.drop("COMP_WORD_".length).toInt, word) | ||
// }.toList.sortBy(_._1).map(_._2) | ||
// Completion | ||
// .complete(compWords, index, self.command, self.config) | ||
// .flatMap { completions => | ||
// ZIO.foreachDiscard(completions)(word => printLine(word)) | ||
// } | ||
// } | ||
console.log("Showing Completions"); | ||
}), | ||
ShowCompletionScript: () => Effect.sync(() => { | ||
// case ShowCompletionScript(path, shellType) => | ||
// printLine( | ||
// CompletionScript(path, if (self.command.names.nonEmpty) self.command.names else Set(self.name), shellType) | ||
// ) | ||
console.log("Showing Completion Script"); | ||
}), | ||
ShowCompletions: () => | ||
// case ShowCompletions(index, _) => | ||
// envs.flatMap { envMap => | ||
// val compWords = envMap.collect { | ||
// case (idx, word) if idx.startsWith("COMP_WORD_") => | ||
// (idx.drop("COMP_WORD_".length).toInt, word) | ||
// }.toList.sortBy(_._1).map(_._2) | ||
// Completion | ||
// .complete(compWords, index, self.command, self.config) | ||
// .flatMap { completions => | ||
// ZIO.foreachDiscard(completions)(word => printLine(word)) | ||
// } | ||
// } | ||
Console.log("Showing Completions"), | ||
ShowCompletionScript: () => | ||
// case ShowCompletionScript(path, shellType) => | ||
// printLine( | ||
// CompletionScript(path, if (self.command.names.nonEmpty) self.command.names else Set(self.name), shellType) | ||
// ) | ||
Console.log("Showing Completion Script"), | ||
ShowHelp: (self, cliApp) => { | ||
@@ -79,18 +77,17 @@ const banner = doc.h1(span.code(cliApp.name)); | ||
}, | ||
Wizard: () => Effect.sync(() => { | ||
// val subcommands = command.getSubcommands | ||
// for { | ||
// subcommandName <- if (subcommands.size == 1) ZIO.succeed(subcommands.keys.head) | ||
// else | ||
// (print("Command" + subcommands.keys.mkString("(", "|", "): ")) *> readLine).orDie | ||
// subcommand <- | ||
// ZIO | ||
// .fromOption(subcommands.get(subcommandName)) | ||
// .orElseFail(ValidationError(ValidationErrorType.InvalidValue, HelpDoc.p("Invalid subcommand"))) | ||
// args <- subcommand.generateArgs | ||
// _ <- Console.printLine(s"Executing command: ${(prefix(self.command) ++ args).mkString(" ")}") | ||
// result <- self.run(args) | ||
// } yield result | ||
console.log("Running Wizard"); | ||
}) | ||
Wizard: () => | ||
// val subcommands = command.getSubcommands | ||
// for { | ||
// subcommandName <- if (subcommands.size == 1) ZIO.succeed(subcommands.keys.head) | ||
// else | ||
// (print("Command" + subcommands.keys.mkString("(", "|", "): ")) *> readLine).orDie | ||
// subcommand <- | ||
// ZIO | ||
// .fromOption(subcommands.get(subcommandName)) | ||
// .orElseFail(ValidationError(ValidationErrorType.InvalidValue, HelpDoc.p("Invalid subcommand"))) | ||
// args <- subcommand.generateArgs | ||
// _ <- Console.printLine(s"Executing command: ${(prefix(self.command) ++ args).mkString(" ")}") | ||
// result <- self.run(args) | ||
// } yield result | ||
Console.log("Running Wizard") | ||
}; | ||
@@ -97,0 +94,0 @@ const runBuiltIn = (self, cliApp) => runBuiltInMap[self._tag](self, cliApp); |
{ | ||
"name": "@effect/cli", | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"description": "Functional programming in TypeScript", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -5,3 +5,2 @@ /** | ||
import type { Command } from "@effect/cli/Command" | ||
import type { Console } from "@effect/cli/Console" | ||
import type { HelpDoc } from "@effect/cli/HelpDoc" | ||
@@ -29,13 +28,2 @@ import type { Span } from "@effect/cli/HelpDoc/Span" | ||
* @since 1.0.0 | ||
*/ | ||
export declare namespace CliApp { | ||
/** | ||
* @since 1.0.0 | ||
* @category models | ||
*/ | ||
export type Context = Console | ||
} | ||
/** | ||
* @since 1.0.0 | ||
* @category constructors | ||
@@ -60,9 +48,9 @@ */ | ||
args: ReadonlyArray<string>, | ||
f: (a: A) => Effect<CliApp.Context | R, E, void> | ||
): (self: CliApp<A>) => Effect<CliApp.Context | R, E | ValidationError, void> | ||
f: (a: A) => Effect<R, E, void> | ||
): (self: CliApp<A>) => Effect<R, E | ValidationError, void> | ||
<R, E, A>( | ||
self: CliApp<A>, | ||
args: ReadonlyArray<string>, | ||
f: (a: A) => Effect<CliApp.Context | R, E, void> | ||
): Effect<CliApp.Context | R, ValidationError | E, void> | ||
f: (a: A) => Effect<R, E, void> | ||
): Effect<R, ValidationError | E, void> | ||
} = internal.run |
import type * as BuiltInOption from "@effect/cli/BuiltInOption" | ||
import type * as CliApp from "@effect/cli/CliApp" | ||
import type * as Command from "@effect/cli/Command" | ||
import * as Console from "@effect/cli/Console" | ||
import type * as HelpDoc from "@effect/cli/HelpDoc" | ||
@@ -18,2 +17,3 @@ import type * as Span from "@effect/cli/HelpDoc/Span" | ||
import * as Option from "@effect/data/Option" | ||
import * as Console from "@effect/io/Console" | ||
import * as Effect from "@effect/io/Effect" | ||
@@ -39,9 +39,9 @@ | ||
args: ReadonlyArray<string>, | ||
f: (a: A) => Effect.Effect<R | CliApp.CliApp.Context, E, void> | ||
) => (self: CliApp.CliApp<A>) => Effect.Effect<R | CliApp.CliApp.Context, E | ValidationError.ValidationError, void>, | ||
f: (a: A) => Effect.Effect<R, E, void> | ||
) => (self: CliApp.CliApp<A>) => Effect.Effect<R, E | ValidationError.ValidationError, void>, | ||
<R, E, A>( | ||
self: CliApp.CliApp<A>, | ||
args: ReadonlyArray<string>, | ||
f: (a: A) => Effect.Effect<R | CliApp.CliApp.Context, E, void> | ||
) => Effect.Effect<R | CliApp.CliApp.Context, E | ValidationError.ValidationError, void> | ||
f: (a: A) => Effect.Effect<R, E, void> | ||
) => Effect.Effect<R, E | ValidationError.ValidationError, void> | ||
>(3, (self, args, f) => | ||
@@ -84,29 +84,25 @@ Effect.contextWithEffect((context: Context.Context<never>) => { | ||
cliApp: CliApp.CliApp<any> | ||
) => Effect.Effect<CliApp.CliApp.Context, never, void> | ||
) => Effect.Effect<never, never, void> | ||
} = { | ||
ShowCompletions: () => | ||
Effect.sync(() => { | ||
// case ShowCompletions(index, _) => | ||
// envs.flatMap { envMap => | ||
// val compWords = envMap.collect { | ||
// case (idx, word) if idx.startsWith("COMP_WORD_") => | ||
// (idx.drop("COMP_WORD_".length).toInt, word) | ||
// }.toList.sortBy(_._1).map(_._2) | ||
// case ShowCompletions(index, _) => | ||
// envs.flatMap { envMap => | ||
// val compWords = envMap.collect { | ||
// case (idx, word) if idx.startsWith("COMP_WORD_") => | ||
// (idx.drop("COMP_WORD_".length).toInt, word) | ||
// }.toList.sortBy(_._1).map(_._2) | ||
// Completion | ||
// .complete(compWords, index, self.command, self.config) | ||
// .flatMap { completions => | ||
// ZIO.foreachDiscard(completions)(word => printLine(word)) | ||
// } | ||
// } | ||
console.log("Showing Completions") | ||
}), | ||
// Completion | ||
// .complete(compWords, index, self.command, self.config) | ||
// .flatMap { completions => | ||
// ZIO.foreachDiscard(completions)(word => printLine(word)) | ||
// } | ||
// } | ||
Console.log("Showing Completions"), | ||
ShowCompletionScript: () => | ||
Effect.sync(() => { | ||
// case ShowCompletionScript(path, shellType) => | ||
// printLine( | ||
// CompletionScript(path, if (self.command.names.nonEmpty) self.command.names else Set(self.name), shellType) | ||
// ) | ||
console.log("Showing Completion Script") | ||
}), | ||
// case ShowCompletionScript(path, shellType) => | ||
// printLine( | ||
// CompletionScript(path, if (self.command.names.nonEmpty) self.command.names else Set(self.name), shellType) | ||
// ) | ||
Console.log("Showing Completion Script"), | ||
ShowHelp: (self, cliApp) => { | ||
@@ -131,18 +127,16 @@ const banner = doc.h1(span.code(cliApp.name)) | ||
Wizard: () => | ||
Effect.sync(() => { | ||
// val subcommands = command.getSubcommands | ||
// for { | ||
// subcommandName <- if (subcommands.size == 1) ZIO.succeed(subcommands.keys.head) | ||
// else | ||
// (print("Command" + subcommands.keys.mkString("(", "|", "): ")) *> readLine).orDie | ||
// subcommand <- | ||
// ZIO | ||
// .fromOption(subcommands.get(subcommandName)) | ||
// .orElseFail(ValidationError(ValidationErrorType.InvalidValue, HelpDoc.p("Invalid subcommand"))) | ||
// args <- subcommand.generateArgs | ||
// _ <- Console.printLine(s"Executing command: ${(prefix(self.command) ++ args).mkString(" ")}") | ||
// result <- self.run(args) | ||
// } yield result | ||
console.log("Running Wizard") | ||
}) | ||
// val subcommands = command.getSubcommands | ||
// for { | ||
// subcommandName <- if (subcommands.size == 1) ZIO.succeed(subcommands.keys.head) | ||
// else | ||
// (print("Command" + subcommands.keys.mkString("(", "|", "): ")) *> readLine).orDie | ||
// subcommand <- | ||
// ZIO | ||
// .fromOption(subcommands.get(subcommandName)) | ||
// .orElseFail(ValidationError(ValidationErrorType.InvalidValue, HelpDoc.p("Invalid subcommand"))) | ||
// args <- subcommand.generateArgs | ||
// _ <- Console.printLine(s"Executing command: ${(prefix(self.command) ++ args).mkString(" ")}") | ||
// result <- self.run(args) | ||
// } yield result | ||
Console.log("Running Wizard") | ||
} | ||
@@ -153,4 +147,4 @@ | ||
cliApp: CliApp.CliApp<A> | ||
): Effect.Effect<CliApp.CliApp.Context, never, void> => runBuiltInMap[self._tag](self as any, cliApp) | ||
): Effect.Effect<never, never, void> => runBuiltInMap[self._tag](self as any, cliApp) | ||
const printDocs = (error: ValidationError.ValidationError) => Console.log(doc.toAnsiText(error.error)) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
731310
212
12010