Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,16 @@ export class CommandFlagsAnnotation extends Context.Service<
() => ReadonlyArray<PermissionFlag>
>()("supabase/CommandFlags") {}

function isMapParam(param: Param.Any): param is Param.Map<Param.ParamKind, unknown, unknown> {
return param._tag === "Map" && "param" in param && "f" in param && typeof param.f === "function";
function isTransformParam(
param: Param.Any,
): param is Param.Transform<Param.ParamKind, unknown, unknown> {
return param._tag === "Transform";
}

/**
* The value `Flag.withDefault` gives an absent flag, read from the `Map` over `Optional` it builds.
* Any other shape, a throwing mapper or a non-string result yields no default.
*/
/** The value `Flag.withDefault` records for an absent flag, when it is a plain string. */
function defaultOf(param: Param.Any): string | undefined {
if (!isMapParam(param) || param.param._tag !== "Optional") return undefined;
try {
const value = param.f(Option.none());
return typeof value === "string" ? value : undefined;
} catch {
return undefined;
}
if (!isTransformParam(param) || param.fallback?._tag !== "Default") return undefined;
return typeof param.fallback.value === "string" ? param.fallback.value : undefined;
}

export function permissionFlagsOf(
Expand Down
3 changes: 2 additions & 1 deletion apps/cli/src/config/cli-config-flags.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Context, Option } from "effect";
import { Command, Flag, type Param } from "effect/cli";
import { Command, Flag, Param } from "effect/cli";

import { sameDocumentValue } from "./cli-config-document.ts";
import type { CliConfigCodec, CliConfigKey } from "./cli-config-key.ts";
Expand Down Expand Up @@ -203,6 +203,7 @@ const collectBound = (
found.push({ accessor, binding });
return;
}
if (Param.isParam(node)) return;
if (Array.isArray(node)) {
node.forEach((child, index) => collectBound(child, [...accessor, index], found));
return;
Expand Down

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions patches/effect@4.1.2.patch → patches/effect@4.1.4.patch
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ index f42ac740a5927835f288afb938bec0dcf2dbeab8..35051ba558fb365321cd6b9ab4235fc7
* Constructs a `Channel` from a scoped effect that will result in a
* `Channel` if successful.
diff --git a/dist/cli/Command.js b/dist/cli/Command.js
index 0561587191e2fe2fff812729b955db15b3224568..8285aac8ee9a25894744100a1129982262ff31d8 100644
index 9c67ae30db1156ee40b5b321bbac3600a84f0822..8e682fc43692920ba3db3ad1989f6c74ace55e76 100644
--- a/dist/cli/Command.js
+++ b/dist/cli/Command.js
@@ -1192,7 +1192,8 @@ export const runWith = (command, config) => {
@@ -1266,7 +1266,8 @@ export const runWith = (command, config) => {
return entries !== undefined && entries.length > 0;
});
if (!hasEntry) continue;
Expand All @@ -27,8 +27,8 @@ index 0561587191e2fe2fff812729b955db15b3224568..8285aac8ee9a25894744100a11299822
if (flag === GlobalFlag.Wizard) {
const {
colors
@@ -1233,11 +1234,12 @@ export const runWith = (command, config) => {
const input = yield* commandImpl.parse(parsedArgs).pipe(toShowHelp);
@@ -1311,11 +1312,12 @@ export const runWith = (command, config) => {
const input = yield* commandImpl.parse(parsedArgs).pipe(Effect.mapError(error => CliError.isCliError(error) ? toShowHelpError(error) : error));
// 7. Provide setting values
let program = commandImpl.handle(input, [command.name]);
- const logLevel = activeFlags.includes(GlobalFlag.LogLevel) ? (yield* GlobalFlag.LogLevel.flag.parse(emptyArgs).pipe(toShowHelp))[1] : Option.none();
Expand Down Expand Up @@ -57,10 +57,10 @@ index 843c67241055adb98092c84e1bf982025ba293f2..d1993f3fdeade431f24d0c29c894bcc4
command
}) {
diff --git a/dist/cli/Param.js b/dist/cli/Param.js
index d6e1f3a78af446ab70776fdc451b385923bdf05d..a027da3b86e8af7998cf4a95fdec672331a55311 100644
index 11212817542775381f89b15c32c00cbda3a72a19..afc5d37f469c57137a6527951f1e5b3a14a1d0b8 100644
--- a/dist/cli/Param.js
+++ b/dist/cli/Param.js
@@ -1486,14 +1486,8 @@ const parseFlag = /*#__PURE__*/Effect.fnUntraced(function* (name, primitiveType,
@@ -1539,14 +1539,8 @@ const parseFlag = /*#__PURE__*/Effect.fnUntraced(function* (name, primitiveType,
option: name
});
}
Expand All @@ -78,12 +78,12 @@ index d6e1f3a78af446ab70776fdc451b385923bdf05d..a027da3b86e8af7998cf4a95fdec6723
const value = yield* Effect.mapError(primitiveType.parse(arg), error => new CliError.InvalidValue({
option: name,
diff --git a/dist/cli/internal/completions/bash.js b/dist/cli/internal/completions/bash.js
index c7d92426383c57362b517d89c8739a36eb69fc4a..f20326850994b8e715e52cb716c07b81bee9dfad 100644
index af3df05343bb810c35dcf00229fc1c865a892179..4e21687e5e5f5f1d3fc8001a2bde4c4ad4c9ad05 100644
--- a/dist/cli/internal/completions/bash.js
+++ b/dist/cli/internal/completions/bash.js
@@ -154,7 +154,9 @@ const valueCompletion = (type, helpers) => {
return `${helpers.choices} "$cur" "$_comp_word" ${values}`;
}
@@ -153,7 +153,9 @@ const valueCompletion = (type, helpers) => {
case "Choice":
return choicesCompletion(type.values, helpers);
case "Path":
- return `${helpers.paths} ${type.pathType === "directory" ? "-d" : "-f"} "$cur" "$_comp_word"`;
+ // TODO(CLI-2922): keeps 4.0's plain compgen path completion until the next major.
Expand All @@ -92,7 +92,7 @@ index c7d92426383c57362b517d89c8739a36eb69fc4a..f20326850994b8e715e52cb716c07b81
default:
return undefined;
}
@@ -353,7 +355,6 @@ export const generate = (executableName, descriptor) => {
@@ -352,7 +354,6 @@ export const generate = (executableName, descriptor) => {
lines.push(`fi`);
lines.push(``);
choicesHelper(helpers.choices, lines);
Expand All @@ -101,7 +101,7 @@ index c7d92426383c57362b517d89c8739a36eb69fc4a..f20326850994b8e715e52cb716c07b81
lines.push(`complete -F _${safeName} ${escapeForBash(executableName)}`);
lines.push(`###-end-${escapeForBash(executableName)}-completions-###`);
diff --git a/dist/cli/internal/completions/zsh.js b/dist/cli/internal/completions/zsh.js
index c8ea8917cfef77b940484443a41d986c95bd9abe..561d27462af270f0504b19c60a87644313e9e33a 100644
index c2a8b0bd5b2c0c11395f0d102c78d4ea5f40e923..7e8f01ea53a2b7653a2302098ccaa4dc44af3a65 100644
--- a/dist/cli/internal/completions/zsh.js
+++ b/dist/cli/internal/completions/zsh.js
@@ -3,7 +3,8 @@ import { negatedName } from "./descriptor.js";
Expand Down
Loading
Loading