@effect/cli
Advanced tools
Comparing version 0.30.4 to 0.30.5
@@ -231,4 +231,4 @@ "use strict"; | ||
const withSchema = exports.withSchema = /*#__PURE__*/(0, _Function.dual)(2, (self, schema) => { | ||
const decode = Schema.decodeEither(schema); | ||
return mapEffect(self, _ => Either.mapLeft(decode(_), error => InternalHelpDoc.p(TreeFormatter.formatIssue(error.error)))); | ||
const decode = Schema.decode(schema); | ||
return mapEffect(self, _ => Effect.mapError(decode(_), error => InternalHelpDoc.p(TreeFormatter.formatIssue(error.error)))); | ||
}); | ||
@@ -235,0 +235,0 @@ /** @internal */ |
@@ -1017,3 +1017,3 @@ "use strict"; | ||
const normalizedHead = normalize(head); | ||
const normalizedNames = ReadonlyArray.map(getNames(self), normalize); | ||
const normalizedNames = ReadonlyArray.map(getNames(self), name => normalize(name)); | ||
if (ReadonlyArray.contains(normalizedNames, normalizedHead)) { | ||
@@ -1092,3 +1092,3 @@ if (InternalPrimitive.isBool(self.primitiveType)) { | ||
{ | ||
const singleNames = ReadonlyArray.map(getNames(self.argumentOption), name => InternalCliConfig.normalizeCase(config, name)); | ||
const normalizedNames = ReadonlyArray.map(getNames(self.argumentOption), name => InternalCliConfig.normalizeCase(config, name)); | ||
return ReadonlyArray.matchLeft(args, { | ||
@@ -1104,6 +1104,6 @@ onEmpty: () => Effect.succeed({ | ||
while (ReadonlyArray.isNonEmptyReadonlyArray(leftover)) { | ||
const name = leftover[0].trim(); | ||
const name = ReadonlyArray.headNonEmpty(leftover).trim(); | ||
const normalizedName = InternalCliConfig.normalizeCase(config, name); | ||
// Can be in the form of "--flag key1=value1 --flag key2=value2" | ||
if (leftover.length >= 2 && ReadonlyArray.contains(singleNames, normalizedName)) { | ||
if (leftover.length >= 2 && ReadonlyArray.contains(normalizedNames, normalizedName)) { | ||
const keyValue = leftover[1].trim(); | ||
@@ -1130,8 +1130,8 @@ const [key, value] = keyValue.split("="); | ||
}; | ||
const name = InternalCliConfig.normalizeCase(config, head); | ||
if (ReadonlyArray.contains(singleNames, name)) { | ||
const normalizedName = InternalCliConfig.normalizeCase(config, head); | ||
if (ReadonlyArray.contains(normalizedNames, normalizedName)) { | ||
const [values, leftover] = loop(tail); | ||
return Effect.succeed({ | ||
parsed: Option.some({ | ||
name, | ||
name: head, | ||
values | ||
@@ -1151,3 +1151,3 @@ }), | ||
{ | ||
const singleNames = ReadonlyArray.map(getNames(self.argumentOption), name => InternalCliConfig.normalizeCase(config, name)); | ||
const normalizedNames = ReadonlyArray.map(getNames(self.argumentOption), name => InternalCliConfig.normalizeCase(config, name)); | ||
let optionName = undefined; | ||
@@ -1157,4 +1157,5 @@ let values = ReadonlyArray.empty(); | ||
while (ReadonlyArray.isNonEmptyReadonlyArray(leftover)) { | ||
const name = InternalCliConfig.normalizeCase(config, ReadonlyArray.headNonEmpty(leftover)); | ||
if (leftover.length >= 2 && ReadonlyArray.contains(singleNames, name)) { | ||
const name = ReadonlyArray.headNonEmpty(leftover); | ||
const normalizedName = InternalCliConfig.normalizeCase(config, name); | ||
if (leftover.length >= 2 && ReadonlyArray.contains(normalizedNames, normalizedName)) { | ||
if (optionName === undefined) { | ||
@@ -1161,0 +1162,0 @@ optionName = name; |
@@ -327,7 +327,7 @@ "use strict"; | ||
{ | ||
return attempt(value, getTypeNameInternal(self), Schema.parse(Schema.Date)); | ||
return attempt(value, getTypeNameInternal(self), Schema.decodeUnknown(Schema.Date)); | ||
} | ||
case "Float": | ||
{ | ||
return attempt(value, getTypeNameInternal(self), Schema.parse(Schema.NumberFromString)); | ||
return attempt(value, getTypeNameInternal(self), Schema.decodeUnknown(Schema.NumberFromString)); | ||
} | ||
@@ -337,3 +337,3 @@ case "Integer": | ||
const intFromString = Schema.compose(Schema.NumberFromString, Schema.Int); | ||
return attempt(value, getTypeNameInternal(self), Schema.parse(intFromString)); | ||
return attempt(value, getTypeNameInternal(self), Schema.decodeUnknown(intFromString)); | ||
} | ||
@@ -349,7 +349,7 @@ case "Path": | ||
{ | ||
return attempt(value, getTypeNameInternal(self), Schema.parse(Schema.string)).pipe(Effect.map(value => EffectSecret.fromString(value))); | ||
return attempt(value, getTypeNameInternal(self), Schema.decodeUnknown(Schema.string)).pipe(Effect.map(value => EffectSecret.fromString(value))); | ||
} | ||
case "Text": | ||
{ | ||
return attempt(value, getTypeNameInternal(self), Schema.parse(Schema.string)); | ||
return attempt(value, getTypeNameInternal(self), Schema.decodeUnknown(Schema.string)); | ||
} | ||
@@ -356,0 +356,0 @@ } |
@@ -48,4 +48,4 @@ "use strict"; | ||
}; | ||
const parseInt = /*#__PURE__*/Schema.NumberFromString.pipe( /*#__PURE__*/Schema.int(), Schema.parse); | ||
const parseFloat = /*#__PURE__*/Schema.parse(Schema.NumberFromString); | ||
const parseInt = /*#__PURE__*/Schema.NumberFromString.pipe( /*#__PURE__*/Schema.int(), Schema.decodeUnknown); | ||
const parseFloat = /*#__PURE__*/Schema.decodeUnknown(Schema.NumberFromString); | ||
const renderBeep = /*#__PURE__*/Doc.render(Doc.beep, { | ||
@@ -52,0 +52,0 @@ style: "pretty" |
@@ -212,3 +212,3 @@ /** | ||
*/ | ||
export declare const fileSchema: <I, A>(schema: Schema<I, A>, config?: Args.FormatArgsConfig | undefined) => Args<A>; | ||
export declare const fileSchema: <I, A>(schema: Schema<FileSystem | Path | Terminal, I, A>, config?: Args.FormatArgsConfig | undefined) => Args<A>; | ||
/** | ||
@@ -377,4 +377,4 @@ * Creates a file argument that reads it's contents. | ||
export declare const withSchema: { | ||
<A, I extends A, B>(schema: Schema<I, B>): (self: Args<A>) => Args<B>; | ||
<A, I extends A, B>(self: Args<A>, schema: Schema<I, B>): Args<B>; | ||
<A, I extends A, B>(schema: Schema<FileSystem | Path | Terminal, I, B>): (self: Args<A>) => Args<B>; | ||
<A, I extends A, B>(self: Args<A>, schema: Schema<FileSystem | Path | Terminal, I, B>): Args<B>; | ||
}; | ||
@@ -381,0 +381,0 @@ /** |
@@ -200,3 +200,3 @@ /** | ||
*/ | ||
export declare const fileSchema: <I, A>(name: string, schema: Schema<I, A>, format?: "json" | "yaml" | "ini" | "toml" | undefined) => Options<A>; | ||
export declare const fileSchema: <I, A>(name: string, schema: Schema<FileSystem | Path | Terminal, I, A>, format?: "json" | "yaml" | "ini" | "toml" | undefined) => Options<A>; | ||
/** | ||
@@ -427,4 +427,4 @@ * Creates a parameter expecting path to a file and reads its contents. | ||
export declare const withSchema: { | ||
<A, I extends A, B>(schema: Schema<I, B>): (self: Options<A>) => Options<B>; | ||
<A, I extends A, B>(self: Options<A>, schema: Schema<I, B>): Options<B>; | ||
<A, I extends A, B>(schema: Schema<FileSystem | Path | Terminal, I, B>): (self: Options<A>) => Options<B>; | ||
<A, I extends A, B>(self: Options<A>, schema: Schema<FileSystem | Path | Terminal, I, B>): Options<B>; | ||
}; | ||
@@ -431,0 +431,0 @@ /** |
@@ -169,4 +169,4 @@ import * as Schema from "@effect/schema/Schema"; | ||
export const withSchema = /*#__PURE__*/dual(2, (self, schema) => { | ||
const decode = Schema.decodeEither(schema); | ||
return mapEffect(self, _ => Either.mapLeft(decode(_), error => InternalHelpDoc.p(TreeFormatter.formatIssue(error.error)))); | ||
const decode = Schema.decode(schema); | ||
return mapEffect(self, _ => Effect.mapError(decode(_), error => InternalHelpDoc.p(TreeFormatter.formatIssue(error.error)))); | ||
}); | ||
@@ -173,0 +173,0 @@ /** @internal */ |
@@ -951,3 +951,3 @@ import * as Schema from "@effect/schema/Schema"; | ||
const normalizedHead = normalize(head); | ||
const normalizedNames = ReadonlyArray.map(getNames(self), normalize); | ||
const normalizedNames = ReadonlyArray.map(getNames(self), name => normalize(name)); | ||
if (ReadonlyArray.contains(normalizedNames, normalizedHead)) { | ||
@@ -1026,3 +1026,3 @@ if (InternalPrimitive.isBool(self.primitiveType)) { | ||
{ | ||
const singleNames = ReadonlyArray.map(getNames(self.argumentOption), name => InternalCliConfig.normalizeCase(config, name)); | ||
const normalizedNames = ReadonlyArray.map(getNames(self.argumentOption), name => InternalCliConfig.normalizeCase(config, name)); | ||
return ReadonlyArray.matchLeft(args, { | ||
@@ -1038,6 +1038,6 @@ onEmpty: () => Effect.succeed({ | ||
while (ReadonlyArray.isNonEmptyReadonlyArray(leftover)) { | ||
const name = leftover[0].trim(); | ||
const name = ReadonlyArray.headNonEmpty(leftover).trim(); | ||
const normalizedName = InternalCliConfig.normalizeCase(config, name); | ||
// Can be in the form of "--flag key1=value1 --flag key2=value2" | ||
if (leftover.length >= 2 && ReadonlyArray.contains(singleNames, normalizedName)) { | ||
if (leftover.length >= 2 && ReadonlyArray.contains(normalizedNames, normalizedName)) { | ||
const keyValue = leftover[1].trim(); | ||
@@ -1064,8 +1064,8 @@ const [key, value] = keyValue.split("="); | ||
}; | ||
const name = InternalCliConfig.normalizeCase(config, head); | ||
if (ReadonlyArray.contains(singleNames, name)) { | ||
const normalizedName = InternalCliConfig.normalizeCase(config, head); | ||
if (ReadonlyArray.contains(normalizedNames, normalizedName)) { | ||
const [values, leftover] = loop(tail); | ||
return Effect.succeed({ | ||
parsed: Option.some({ | ||
name, | ||
name: head, | ||
values | ||
@@ -1085,3 +1085,3 @@ }), | ||
{ | ||
const singleNames = ReadonlyArray.map(getNames(self.argumentOption), name => InternalCliConfig.normalizeCase(config, name)); | ||
const normalizedNames = ReadonlyArray.map(getNames(self.argumentOption), name => InternalCliConfig.normalizeCase(config, name)); | ||
let optionName = undefined; | ||
@@ -1091,4 +1091,5 @@ let values = ReadonlyArray.empty(); | ||
while (ReadonlyArray.isNonEmptyReadonlyArray(leftover)) { | ||
const name = InternalCliConfig.normalizeCase(config, ReadonlyArray.headNonEmpty(leftover)); | ||
if (leftover.length >= 2 && ReadonlyArray.contains(singleNames, name)) { | ||
const name = ReadonlyArray.headNonEmpty(leftover); | ||
const normalizedName = InternalCliConfig.normalizeCase(config, name); | ||
if (leftover.length >= 2 && ReadonlyArray.contains(normalizedNames, normalizedName)) { | ||
if (optionName === undefined) { | ||
@@ -1095,0 +1096,0 @@ optionName = name; |
@@ -280,7 +280,7 @@ import * as FileSystem from "@effect/platform/FileSystem"; | ||
{ | ||
return attempt(value, getTypeNameInternal(self), Schema.parse(Schema.Date)); | ||
return attempt(value, getTypeNameInternal(self), Schema.decodeUnknown(Schema.Date)); | ||
} | ||
case "Float": | ||
{ | ||
return attempt(value, getTypeNameInternal(self), Schema.parse(Schema.NumberFromString)); | ||
return attempt(value, getTypeNameInternal(self), Schema.decodeUnknown(Schema.NumberFromString)); | ||
} | ||
@@ -290,3 +290,3 @@ case "Integer": | ||
const intFromString = Schema.compose(Schema.NumberFromString, Schema.Int); | ||
return attempt(value, getTypeNameInternal(self), Schema.parse(intFromString)); | ||
return attempt(value, getTypeNameInternal(self), Schema.decodeUnknown(intFromString)); | ||
} | ||
@@ -302,7 +302,7 @@ case "Path": | ||
{ | ||
return attempt(value, getTypeNameInternal(self), Schema.parse(Schema.string)).pipe(Effect.map(value => EffectSecret.fromString(value))); | ||
return attempt(value, getTypeNameInternal(self), Schema.decodeUnknown(Schema.string)).pipe(Effect.map(value => EffectSecret.fromString(value))); | ||
} | ||
case "Text": | ||
{ | ||
return attempt(value, getTypeNameInternal(self), Schema.parse(Schema.string)); | ||
return attempt(value, getTypeNameInternal(self), Schema.decodeUnknown(Schema.string)); | ||
} | ||
@@ -309,0 +309,0 @@ } |
@@ -17,4 +17,4 @@ import * as Terminal from "@effect/platform/Terminal"; | ||
}; | ||
const parseInt = /*#__PURE__*/Schema.NumberFromString.pipe( /*#__PURE__*/Schema.int(), Schema.parse); | ||
const parseFloat = /*#__PURE__*/Schema.parse(Schema.NumberFromString); | ||
const parseInt = /*#__PURE__*/Schema.NumberFromString.pipe( /*#__PURE__*/Schema.int(), Schema.decodeUnknown); | ||
const parseFloat = /*#__PURE__*/Schema.decodeUnknown(Schema.NumberFromString); | ||
const renderBeep = /*#__PURE__*/Doc.render(Doc.beep, { | ||
@@ -21,0 +21,0 @@ style: "pretty" |
{ | ||
"name": "@effect/cli", | ||
"version": "0.30.4", | ||
"version": "0.30.5", | ||
"description": "Functional programming in TypeScript", | ||
@@ -17,7 +17,7 @@ "license": "MIT", | ||
"peerDependencies": { | ||
"@effect/platform": "^0.42.7", | ||
"@effect/printer": "^0.30.9", | ||
"@effect/printer-ansi": "^0.31.9", | ||
"@effect/schema": "^0.60.7", | ||
"effect": "^2.2.0" | ||
"@effect/platform": "^0.43.0", | ||
"@effect/printer": "^0.30.10", | ||
"@effect/printer-ansi": "^0.31.10", | ||
"@effect/schema": "^0.61.0", | ||
"effect": "^2.2.1" | ||
}, | ||
@@ -24,0 +24,0 @@ "main": "./dist/cjs/index.js", |
@@ -255,4 +255,6 @@ /** | ||
*/ | ||
export const fileSchema: <I, A>(schema: Schema<I, A>, config?: Args.FormatArgsConfig | undefined) => Args<A> = | ||
InternalArgs.fileSchema | ||
export const fileSchema: <I, A>( | ||
schema: Schema<FileSystem | Path | Terminal, I, A>, | ||
config?: Args.FormatArgsConfig | undefined | ||
) => Args<A> = InternalArgs.fileSchema | ||
@@ -454,4 +456,4 @@ /** | ||
export const withSchema: { | ||
<A, I extends A, B>(schema: Schema<I, B>): (self: Args<A>) => Args<B> | ||
<A, I extends A, B>(self: Args<A>, schema: Schema<I, B>): Args<B> | ||
<A, I extends A, B>(schema: Schema<FileSystem | Path | Terminal, I, B>): (self: Args<A>) => Args<B> | ||
<A, I extends A, B>(self: Args<A>, schema: Schema<FileSystem | Path | Terminal, I, B>): Args<B> | ||
} = InternalArgs.withSchema | ||
@@ -458,0 +460,0 @@ |
@@ -233,3 +233,3 @@ import type * as FileSystem from "@effect/platform/FileSystem" | ||
export const fileSchema = <I, A>( | ||
schema: Schema.Schema<I, A>, | ||
schema: Schema.Schema<FileSystem.FileSystem | Path.Path | Terminal.Terminal, I, A>, | ||
config?: Args.Args.FormatArgsConfig | ||
@@ -427,8 +427,13 @@ ): Args.Args<A> => withSchema(fileParse(config), schema) | ||
export const withSchema = dual< | ||
<A, I extends A, B>(schema: Schema.Schema<I, B>) => (self: Args.Args<A>) => Args.Args<B>, | ||
<A, I extends A, B>(self: Args.Args<A>, schema: Schema.Schema<I, B>) => Args.Args<B> | ||
<A, I extends A, B>( | ||
schema: Schema.Schema<FileSystem.FileSystem | Path.Path | Terminal.Terminal, I, B> | ||
) => (self: Args.Args<A>) => Args.Args<B>, | ||
<A, I extends A, B>( | ||
self: Args.Args<A>, | ||
schema: Schema.Schema<FileSystem.FileSystem | Path.Path | Terminal.Terminal, I, B> | ||
) => Args.Args<B> | ||
>(2, (self, schema) => { | ||
const decode = Schema.decodeEither(schema) | ||
const decode = Schema.decode(schema) | ||
return mapEffect(self, (_) => | ||
Either.mapLeft( | ||
Effect.mapError( | ||
decode(_ as any), | ||
@@ -435,0 +440,0 @@ (error) => InternalHelpDoc.p(TreeFormatter.formatIssue(error.error)) |
@@ -418,10 +418,10 @@ import * as FileSystem from "@effect/platform/FileSystem" | ||
case "DateTime": { | ||
return attempt(value, getTypeNameInternal(self), Schema.parse(Schema.Date)) | ||
return attempt(value, getTypeNameInternal(self), Schema.decodeUnknown(Schema.Date)) | ||
} | ||
case "Float": { | ||
return attempt(value, getTypeNameInternal(self), Schema.parse(Schema.NumberFromString)) | ||
return attempt(value, getTypeNameInternal(self), Schema.decodeUnknown(Schema.NumberFromString)) | ||
} | ||
case "Integer": { | ||
const intFromString = Schema.compose(Schema.NumberFromString, Schema.Int) | ||
return attempt(value, getTypeNameInternal(self), Schema.parse(intFromString)) | ||
return attempt(value, getTypeNameInternal(self), Schema.decodeUnknown(intFromString)) | ||
} | ||
@@ -449,3 +449,3 @@ case "Path": { | ||
case "Secret": { | ||
return attempt(value, getTypeNameInternal(self), Schema.parse(Schema.string)).pipe( | ||
return attempt(value, getTypeNameInternal(self), Schema.decodeUnknown(Schema.string)).pipe( | ||
Effect.map((value) => EffectSecret.fromString(value)) | ||
@@ -455,3 +455,3 @@ ) | ||
case "Text": { | ||
return attempt(value, getTypeNameInternal(self), Schema.parse(Schema.string)) | ||
return attempt(value, getTypeNameInternal(self), Schema.decodeUnknown(Schema.string)) | ||
} | ||
@@ -458,0 +458,0 @@ } |
@@ -29,6 +29,6 @@ import * as Terminal from "@effect/platform/Terminal" | ||
Schema.int(), | ||
Schema.parse | ||
Schema.decodeUnknown | ||
) | ||
const parseFloat = Schema.parse(Schema.NumberFromString) | ||
const parseFloat = Schema.decodeUnknown(Schema.NumberFromString) | ||
@@ -35,0 +35,0 @@ const renderBeep = Doc.render(Doc.beep, { style: "pretty" }) |
@@ -255,3 +255,3 @@ /** | ||
name: string, | ||
schema: Schema<I, A>, | ||
schema: Schema<FileSystem | Path | Terminal, I, A>, | ||
format?: "json" | "yaml" | "ini" | "toml" | undefined | ||
@@ -535,4 +535,4 @@ ) => Options<A> = InternalOptions.fileSchema | ||
export const withSchema: { | ||
<A, I extends A, B>(schema: Schema<I, B>): (self: Options<A>) => Options<B> | ||
<A, I extends A, B>(self: Options<A>, schema: Schema<I, B>): Options<B> | ||
<A, I extends A, B>(schema: Schema<FileSystem | Path | Terminal, I, B>): (self: Options<A>) => Options<B> | ||
<A, I extends A, B>(self: Options<A>, schema: Schema<FileSystem | Path | Terminal, I, B>): Options<B> | ||
} = InternalOptions.withSchema | ||
@@ -539,0 +539,0 @@ |
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
1903568
31698