This repository has been archived by the owner on Jul 16, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
54 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type * as CliApp from "@effect/cli/CliApp" | ||
import * as Command from "@effect/cli/Command" | ||
import * as HelpDoc from "@effect/cli/HelpDoc" | ||
import * as ValidationError from "@effect/cli/ValidationError" | ||
import * as FileSystem from "@effect/platform-node/FileSystem" | ||
import * as Path from "@effect/platform-node/Path" | ||
import * as Terminal from "@effect/platform-node/Terminal" | ||
import { Effect, ReadonlyArray } from "effect" | ||
import * as Layer from "effect/Layer" | ||
import { describe, expect, it } from "vitest" | ||
|
||
const MainLive = Layer.mergeAll(FileSystem.layer, Path.layer, Terminal.layer) | ||
|
||
const runEffect = <E, A>( | ||
self: Effect.Effect<CliApp.CliApp.Environment, E, A> | ||
): Promise<A> => | ||
Effect.provide(self, MainLive).pipe( | ||
Effect.runPromise | ||
) | ||
|
||
describe("CliApp", () => { | ||
it("should return an error if excess arguments are provided", () => | ||
Effect.gen(function*(_) { | ||
const cli = Command.run(Command.make("foo"), { | ||
name: "Test", | ||
version: "1.0.0" | ||
}) | ||
const args = ReadonlyArray.make("--bar") | ||
const result = yield* _(Effect.flip(cli(args))) | ||
expect(result).toEqual(ValidationError.invalidValue(HelpDoc.p( | ||
"Received unknown argument: '--bar'" | ||
))) | ||
}).pipe(runEffect)) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters