(tree: CliTree, rootName?: string): ReturnType<typeof buildCommand>
(tree: CliTree, options: CliOptions): CliRunBuild the Hyperlink control surface from a CliTree.
cli(Fleet, "hyperlink")→ EffectCommand(wire withCommand.runWith)cli(Fleet, { name: "hyperlink", version })→ CliRun (runWith baked in)
export const const cli: {
(tree: CliTree, rootName?: string): ReturnType<
typeof buildCommand
>
(tree: CliTree, options: CliOptions): CliRun
}
Build the Hyperlink control surface from a
CliTree
.
cli(Fleet, "hyperlink") → Effect Command (wire with Command.runWith)
cli(Fleet, { name: "hyperlink", version }) →
CliRun
(runWith baked in)
cli: {
(tree: CliTreetree: type CliTree = CliGroup | Record<string, CliNode>What
cli
accepts: a Group.Tag, or a flat/nested { commandName: node } record.
CliTree, rootName: string | undefinedrootName?: string): type ReturnType<
T extends (...args: any) => any
> = T extends (...args: any) => infer R ? R : any
Obtain the return type of a function type
ReturnType<typeof const buildCommand: (
tree: CliTree,
rootName: string
) => Command.Command<
string,
{},
{},
TuiNotConfigured,
never
>
buildCommand>;
(tree: CliTreetree: type CliTree = CliGroup | Record<string, CliNode>What
cli
accepts: a Group.Tag, or a flat/nested { commandName: node } record.
CliTree, options: CliOptions(parameter) options: {
name: string;
version: string;
}
options: type CliOptions = {
readonly name?: string
readonly version: string
}
CliOptions): type CliRun = (
args: ReadonlyArray<string>
) => Effect.Effect<void, TuiNotConfigured, never>
Args runner from the options overload of
cli
. Provide hyperlink + TUI layers
when you run it.
CliRun;
} = ((tree: CliTreetree: type CliTree = CliGroup | Record<string, CliNode>What
cli
accepts: a Group.Tag, or a flat/nested { commandName: node } record.
CliTree, second: string | CliOptions | undefinedsecond?: string | type CliOptions = {
readonly name?: string
readonly version: string
}
CliOptions) => {
if (typeof second: string | CliOptions | undefinedsecond === "object" && second: CliOptions(parameter) second: {
name: string;
version: string;
}
second !== null) {
return import CommandCommand.const runWith: <
Name extends string,
Input,
E,
R,
ContextInput
>(
command: Command<
Name,
Input,
ContextInput,
E,
R
>,
config: { readonly version: string }
) => (
input: ReadonlyArray<string>
) => Effect.Effect<
void,
| Exclude<E, Terminal.QuitError>
| CliError.CliError,
R | Environment
>
Runs a command with explicitly provided arguments instead of using arguments from Stdio.
When to use
Use when you need to test CLI applications or programmatically execute
commands with specific arguments.
Example (Running commands with explicit arguments)
import { Console, Effect } from "effect"
import { Command, Flag } from "effect/unstable/cli"
const greet = Command.make("greet", {
name: Flag.string("name"),
count: Flag.integer("count").pipe(Flag.withDefault(1))
}, (config) =>
Effect.gen(function*() {
for (let i = 0; i < config.count; i++) {
yield* Console.log(`Hello, ${config.name}!`)
}
}))
// Test with specific arguments
const testProgram = Effect.gen(function*() {
const runCommand = Command.runWith(greet, { version: "1.0.0" })
// Test normal execution
yield* runCommand(["--name", "Alice", "--count", "2"])
// Test help display
yield* runCommand(["--help"])
// Test version display
yield* runCommand(["--version"])
})
runWith(const buildCommand: (
tree: CliTree,
rootName: string
) => Command.Command<
string,
{},
{},
TuiNotConfigured,
never
>
buildCommand(tree: CliTreetree, second: CliOptions(parameter) second: {
name: string;
version: string;
}
second.name?: string | undefinedname ?? "cli"), {
version: stringversion: second: CliOptions(parameter) second: {
name: string;
version: string;
}
second.version: stringversion,
});
}
return const buildCommand: (
tree: CliTree,
rootName: string
) => Command.Command<
string,
{},
{},
TuiNotConfigured,
never
>
buildCommand(tree: CliTreetree, second: string | undefinedsecond ?? "cli");
}) as typeof const cli: {
(tree: CliTree, rootName?: string): ReturnType<
typeof buildCommand
>
(tree: CliTree, options: CliOptions): CliRun
}
Build the Hyperlink control surface from a
CliTree
.
cli(Fleet, "hyperlink") → Effect Command (wire with Command.runWith)
cli(Fleet, { name: "hyperlink", version }) →
CliRun
(runWith baked in)
cli;