Skip to content
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .codex/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
model = "gpt-5.4"
review_model = "gpt-5.4"
model = "gpt-5.5"
review_model = "gpt-5.5"
model_provider = "openai"

approval_policy = "untrusted"
Expand Down
7 changes: 7 additions & 0 deletions .commands/test-lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -e

ARGUMENTS="$@"

eslint --quiet $ARGUMENTS
7 changes: 7 additions & 0 deletions .commands/test-tu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -e

ARGUMENTS="$@"

vitest --coverage $ARGUMENTS
8 changes: 8 additions & 0 deletions .commands/test-types.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -e

tsc -p tsconfig.test.json

# docs
npm -w docs run test:types
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '24.x'
node-version: '22.15.1'
registry-url: 'https://registry.npmjs.org/'
- run: npm install -g npm@latest
- run: npm ci
Expand Down
9 changes: 5 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},

"typescript.tsdk": "node_modules/typescript/lib",

"deno.enable": true,
"deno.enablePaths": ["integration/deno"],
"deno.disablePaths": ["dist", "node_modules"],
"deno.config": "./integration/deno/deno.json"
"deno.config": "./integration/deno/deno.json",
"js/ts.tsdk.path": "node_modules/typescript/lib",
"cSpell.words": [
"vitest"
]
}
6 changes: 6 additions & 0 deletions docs/.commands/test-types.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

set -e

tsc -p tsconfig.app.json
tsc -p tsconfig.v0.json
28 changes: 14 additions & 14 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,25 @@ export default defineConfig({
({ namedGroups }) => A.join(
[
"// @filename: @duplojs/server-utils.ts",
`export * from "@v${namedGroups?.version ?? ""}";`,
`export * from "@server-utils/v${namedGroups?.version ?? ""}";`,

"// @filename: @duplojs/server-utils/file.ts",
`export * from "@v${namedGroups?.version ?? ""}/file";`,
`export * from "@server-utils/v${namedGroups?.version ?? ""}/file";`,

"// @filename: @duplojs/server-utils/common.ts",
`export * from "@v${namedGroups?.version ?? ""}/common";`,
`export * from "@server-utils/v${namedGroups?.version ?? ""}/common";`,

"// @filename: @duplojs/server-utils/dataParser.ts",
`export * from "@v${namedGroups?.version ?? ""}/dataParser";`,
`export * from "@server-utils/v${namedGroups?.version ?? ""}/dataParser";`,

"// @filename: @duplojs/server-utils/dataParserCoerce.ts",
`export * from "@v${namedGroups?.version ?? ""}/dataParserCoerce";`,
`export * from "@server-utils/v${namedGroups?.version ?? ""}/dataParserCoerce";`,

"// @filename: @duplojs/server-utils/dataParserExtended.ts",
`export * from "@v${namedGroups?.version ?? ""}/dataParserExtended";`,
`export * from "@server-utils/v${namedGroups?.version ?? ""}/dataParserExtended";`,

"// @filename: @duplojs/server-utils/command.ts",
`export * from "@v${namedGroups?.version ?? ""}/command";`,
`export * from "@server-utils/v${namedGroups?.version ?? ""}/command";`,

"// @filename: index.ts",
"// ---cut---",
Expand All @@ -134,13 +134,13 @@ export default defineConfig({
moduleResolution: ModuleResolutionKind.Bundler,
moduleDetection: ModuleDetectionKind.Force,
paths: {
"@v0": ["libs/v0/index"],
"@v0/common": ["libs/v0/common/index"],
"@v0/file": ["libs/v0/file/index"],
"@v0/dataParser": ["libs/v0/dataParser/index"],
"@v0/dataParserCoerce": ["libs/v0/dataParser/parsers/coerce/index"],
"@v0/dataParserExtended": ["libs/v0/dataParser/extended/index"],
"@v0/command": ["libs/v0/command/index"],
"@server-utils/v0": ["libs/v0/index"],
"@server-utils/v0/common": ["libs/v0/common/index"],
"@server-utils/v0/file": ["libs/v0/file/index"],
"@server-utils/v0/dataParser": ["libs/v0/dataParser/index"],
"@server-utils/v0/dataParserCoerce": ["libs/v0/dataParser/parsers/coerce/index"],
"@server-utils/v0/dataParserExtended": ["libs/v0/dataParser/extended/index"],
"@server-utils/v0/command": ["libs/v0/command/index"],
},
},
},
Expand Down
13 changes: 6 additions & 7 deletions docs/en/v0/api/command/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ prev:
next:
text: "createBooleanOption"
link: "/en/v0/api/command/createBooleanOption"
description: "Creates a CLI command with a name, an execute handler, and optional configuration."
description: "Creates a CLI command with a name, optional options/subject, and an execute handler."
---

# create

`create` is used to declare a CLI command.
You provide a name and an execute function.
You can also add options, a subject (positional arguments), or sub-commands.
`create` declares a CLI command.
You provide a name and an execute function, and you can also add options, a subject for positional arguments, or child commands.

## Example

Expand Down Expand Up @@ -48,12 +47,12 @@ function create<
- `params` (`CreateCommandParams`, optional) : command configuration.
- `params.description` (`string`, optional) : help description.
- `params.options` (`Option[]`, optional) : option parsers.
- `params.subject` (`Subject | Command[]`, optional) : parser for positional data or sub-commands list.
- `execute` : command handler. Receives typed `options` and optional typed `subject`.
- `params.subject` (`Subject | Command[]`, optional) : parser-like contract for positional data or sub-commands list.
- `execute` : command handler. Receives typed `options` and, when present, a typed `subject`.

## Return value

- `Command` : executable command object with `execute(args)`.
- `Command` : command definition object meant to be attached to a command tree and executed through [`exec`](/en/v0/api/command/exec).

## Others examples

Expand Down
24 changes: 14 additions & 10 deletions docs/en/v0/api/command/createArrayOption.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ prev:
next:
text: "API Reference"
link: "/en/v0/api/"
description: "Creates an option that parses a delimited list into a typed array."
description: "Creates an option that parses a delimited list into a typed array from a DataParser or clean contract."
---

# createArrayOption
Expand All @@ -25,11 +25,11 @@ Creates an option that parses a delimited list into a typed array.
```typescript
function createArrayOption<
GenericName extends string,
GenericSchema extends EligibleDataParser,
GenericContract extends EligibleContract,
GenericMinValues extends number
>(
name: GenericName,
schema: GenericSchema,
contract: GenericContract,
params: {
description?: string
aliases?: readonly string[]
Expand All @@ -41,18 +41,18 @@ function createArrayOption<
): Option<
GenericName,
[
...A.CreateTuple<DP.Output<GenericSchema>, GenericMinValues>,
...DP.Output<GenericSchema>[]
...A.CreateTuple<ComputeOptionContract<GenericContract>, GenericMinValues>,
...ComputeOptionContract<GenericContract>[]
]
>

function createArrayOption<
GenericName extends string,
GenericSchema extends EligibleDataParser,
GenericContract extends EligibleContract,
GenericMinValues extends number
>(
name: GenericName,
schema: GenericSchema,
contract: GenericContract,
params?: {
description?: string
aliases?: readonly string[]
Expand All @@ -63,8 +63,8 @@ function createArrayOption<
): Option<
GenericName,
| [
...A.CreateTuple<DP.Output<GenericSchema>, GenericMinValues>,
...DP.Output<GenericSchema>[]
...A.CreateTuple<ComputeOptionContract<GenericContract>, GenericMinValues>,
...ComputeOptionContract<GenericContract>[]
]
| undefined
>
Expand All @@ -73,7 +73,7 @@ function createArrayOption<
## Parameters

- `name` (`string`) : option name used as `--name`.
- `schema` (`EligibleDataParser`) : parser for each array element.
- `contract` (`EligibleContract`) : parser or clean contract for each array element.
- `params` (optional) : option metadata and array constraints.
- `params.required` (`true`, optional) : throws when option is missing.
- `params.min` (`number`, optional) : minimum number of values.
Expand All @@ -87,6 +87,10 @@ function createArrayOption<
- Required mode: `Option<GenericName, [..items]>`.
- Optional mode: `Option<GenericName, [..items] | undefined>`.

## Notes

- Primitive parsers and clean primitive contracts are coerced from CLI string input automatically.

## See also

- [`createOption`](/en/v0/api/command/createOption) - Builds a single-value option.
Expand Down
28 changes: 17 additions & 11 deletions docs/en/v0/api/command/createOption.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ prev:
next:
text: "createArrayOption"
link: "/en/v0/api/command/createArrayOption"
description: "Creates an option with a single parsed value from a DataParser schema."
description: "Creates an option with a single parsed value from a DataParser or clean contract."
---

# createOption

Creates an option with a single parsed value from a DataParser schema.
Creates an option with a single parsed value from a DataParser or clean contract.

## Example

Expand All @@ -25,43 +25,49 @@ Creates an option with a single parsed value from a DataParser schema.
```typescript
function createOption<
GenericName extends string,
GenericSchema extends EligibleDataParser
GenericContract extends EligibleContract,
GenericOutput extends ComputeOptionContract<GenericContract> = ComputeOptionContract<GenericContract>
>(
name: GenericName,
schema: GenericSchema,
contract: GenericContract,
params: {
description?: string
aliases?: readonly string[]
required: true
}
): Option<GenericName, DP.Output<GenericSchema>>
): Option<GenericName, GenericOutput>

function createOption<
GenericName extends string,
GenericSchema extends EligibleDataParser
GenericContract extends EligibleContract,
GenericOutput extends ComputeOptionContract<GenericContract> = ComputeOptionContract<GenericContract>
>(
name: GenericName,
schema: GenericSchema,
contract: GenericContract,
params?: {
description?: string
aliases?: readonly string[]
}
): Option<GenericName, DP.Output<GenericSchema> | undefined>
): Option<GenericName, GenericOutput | undefined>
```

## Parameters

- `name` (`string`) : option name used as `--name`.
- `schema` (`EligibleDataParser`) : parser used to validate/transform the value.
- `contract` (`EligibleContract`) : parser or clean contract used to validate/transform the value.
- `params` (optional) : option metadata and requirement behavior.
- `params.required` (`true`, optional) : throws when option is missing.
- `params.description` (`string`, optional) : help description.
- `params.aliases` (`string[]`, optional) : short aliases.

## Return value

- `Option<GenericName, DP.Output<GenericSchema>>` when `required: true`.
- `Option<GenericName, DP.Output<GenericSchema> | undefined>` otherwise.
- `Option<GenericName, GenericOutput>` when `required: true`.
- `Option<GenericName, GenericOutput | undefined>` otherwise.

## Notes

- Primitive parsers and clean primitive contracts are coerced from CLI string input automatically.

## See also

Expand Down
6 changes: 3 additions & 3 deletions docs/en/v0/api/command/execOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description: "Parses CLI options from runtime arguments."

# execOptions

`execOptions` parses CLI options and returns the result as a `{ [optionName]: resultOption }` record.
`execOptions` parses CLI options and resolves the result as a `{ [optionName]: resultOption }` record.
If parsing fails, a detailed error is printed to the console.
The `--help` / `-h` output is generated automatically from the declared options.

Expand All @@ -29,7 +29,7 @@ function execOptions<
GenericOptions extends [Option, ...Option[]]
>(
...options: GenericOptions
): ComputeResult<GenericOptions>
): Promise<ComputeResult<GenericOptions>>
```

## Parameters
Expand All @@ -38,7 +38,7 @@ function execOptions<

## Return value

- `ComputeResult<GenericOptions>` : object whose keys are option names and whose values are the typed result of each parser.
- `Promise<ComputeResult<GenericOptions>>` : promise resolving to an object whose keys are option names and whose values are the typed result of each parser.

## See also

Expand Down
Loading
Loading