Skip to content

Commit

Permalink
Start v3 development
Browse files Browse the repository at this point in the history
  • Loading branch information
surol committed Sep 16, 2023
1 parent 51df60e commit 84a1990
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 43 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@run-z/optionz",
"version": "2.4.1",
"version": "3.0.0-pre.0",
"description": "Run-z command line options parser",
"keywords": [
"cli",
Expand All @@ -21,10 +21,10 @@
"types": "./dist/optionz.d.ts",
"typesVersions": {
"*": {
"colors": [
"colors.js": [
"./dist/optionz.colors.d.ts"
],
"help": [
"help.js": [
"./dist/optionz.help.d.ts"
]
}
Expand All @@ -34,23 +34,23 @@
"types": "./dist/optionz.d.ts",
"default": "./dist/optionz.js"
},
"./colors": {
"./colors.js": {
"types": "./dist/optionz.colors.d.ts",
"default": "./dist/optionz.colors.js"
},
"./help": {
"./help.js": {
"types": "./dist/optionz.help.d.ts",
"default": "./dist/optionz.help.js"
}
},
"sideEffects": false,
"dependencies": {
"@proc7ts/primitives": "^3.0.2",
"@proc7ts/primitives": "^4.0.1",
"string-width": "^6.1.0",
"wrap-ansi": "^8.1.0"
},
"peerDependencies": {
"chalk": "^5.0.0"
"chalk": "^5.3.0"
},
"peerDependenciesMeta": {
"chalk": {
Expand Down
2 changes: 1 addition & 1 deletion src/colors/chalk-color-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { ZOption } from '../option';
/**
* Chalk color options configuration.
*
* @typeparam TOption A type of color option.
* @typeParam TOption A type of color option.
*/
export interface ChalkZColorConfig<TOption extends ZOption> {
/**
Expand Down
6 changes: 3 additions & 3 deletions src/colors/chalk-color-options.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { afterEach, beforeEach, describe, expect, it, jest } from '@jest/globals';
import { arrayOfElements, asis, noop } from '@proc7ts/primitives';
import { asArray, asis, noop } from '@proc7ts/primitives';
import type { ColorSupportLevel } from 'chalk';
import chalk from 'chalk';
import type { MockInstance } from 'jest-mock';
import { helpZOptionReader } from '../help';
import { ZOptionError } from '../option-error';
import type { ZOption } from '../option.js';
import { simpleZOptionsParser, SimpleZOptionsParser } from '../simple-options-parser';
import { SimpleZOptionsParser, simpleZOptionsParser } from '../simple-options-parser';
import { type ChalkZColorConfig } from './chalk-color-config.js';
import { chalkZColorOptions } from './chalk-color-options';

Expand Down Expand Up @@ -116,7 +116,7 @@ describe('chalkZColorOptions', () => {
});

it('has help', async () => {
const options = [...arrayOfElements(chalkZColorOptions())];
const options = [...asArray(chalkZColorOptions())];
const display: MockInstance<(...args: unknown[]) => void> & ((...args: unknown[]) => void) =
jest.fn(noop);

Expand Down
2 changes: 1 addition & 1 deletion src/help/help-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { ZOptionMeta } from '../option-meta';
/**
* Configuration for {@link helpZOptionReader help option reader}.
*
* @typeparam TOption A type of help option.
* @typeParam TOption A type of help option.
*/
export interface ZHelpConfig<TOption extends ZOption = ZOption> {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/help/help-option-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ZHelpFormatter } from './help-formatter';
/**
* Creates option reader able to build and print help info.
*
* @typeparam TOption A type of help option.
* @typeParam TOption A type of help option.
* @param config - Help configuration.
*
* @returns New option reader.
Expand Down
10 changes: 5 additions & 5 deletions src/option-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import type { ZOptionMeta } from './option-meta';
*
* This can be either a {@link ZOptionReader.Fn reader function}, or its {@link ZOptionReader.Spec full specifier}.
*
* @typeparam TOption A type of command line option representation expected by reader.
* @typeparam TThis A type of `this` parameter.
* @typeParam TOption A type of command line option representation expected by reader.
* @typeParam TThis A type of `this` parameter.
*/
export type ZOptionReader<TOption extends ZOption = ZOption, TThis = void> =
| ZOptionReader.Fn<TOption, TThis>
Expand All @@ -20,8 +20,8 @@ export namespace ZOptionReader {
* A reader function accepts a {@link ZOption command line option} corresponding to the key the reader is
* {@link SupportedZOptions.Map registered for} and tries to recognize it.
*
* @typeparam TOption A type of command line option representation expected by reader.
* @typeparam TThis A type of `this` parameter.
* @typeParam TOption A type of command line option representation expected by reader.
* @typeParam TThis A type of `this` parameter.
*/
export type Fn<TOption extends ZOption = ZOption, TThis = unknown> =
/**
Expand All @@ -37,7 +37,7 @@ export namespace ZOptionReader {
*
* Contains option reader function along with meta information.
*
* @typeparam TOption A type of command line option representation expected by reader.
* @typeParam TOption A type of command line option representation expected by reader.
*/
export interface Spec<TOption extends ZOption = ZOption> {
/**
Expand Down
4 changes: 2 additions & 2 deletions src/option-syntax.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isArrayOfElements } from '@proc7ts/primitives';
import { isArray } from '@proc7ts/primitives';
import { ZOptionInput } from './option-input';

/**
Expand Down Expand Up @@ -103,7 +103,7 @@ export const ZOptionSyntax = {
* @internal
*/
function zOptionSyntaxBy(syntax: ZOptionSyntax | readonly ZOptionSyntax[]): ZOptionSyntax {
if (!isArrayOfElements(syntax)) {
if (!isArray(syntax)) {
return syntax;
}

Expand Down
8 changes: 4 additions & 4 deletions src/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export namespace ZOption {
*
* This is a class to extend by {@link ZOptionsParser.Config.optionClass options parser}.
*
* @typeparam TArgs A type of constructor arguments.
* @typeParam TArgs A type of constructor arguments.
*/
export interface BaseClass<TArgs extends any[]> {
prototype: ZOption;
Expand All @@ -169,9 +169,9 @@ export namespace ZOption {
/**
* A class constructor representing a parser-specific implementation of the command line option.
*
* @typeparam TOption Parser-specific command line option interface implemented by this class.
* @typeparam TCtx A type of option processing context required by parser.
* @typeparam TArgs A type of arguments to pass to the {@link BaseClass base constructor}.
* @typeParam TOption Parser-specific command line option interface implemented by this class.
* @typeParam TCtx A type of option processing context required by parser.
* @typeParam TArgs A type of arguments to pass to the {@link BaseClass base constructor}.
*/
export interface ImplClass<TOption extends ZOption, TCtx, TArgs extends any[]> {
prototype: TOption;
Expand Down
10 changes: 5 additions & 5 deletions src/options-parser.impl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { arrayOfElements, lazyValue } from '@proc7ts/primitives';
import { asArray, lazyValue } from '@proc7ts/primitives';
import type { ZOption } from './option';
import { ZOptionBase } from './option-base.impl';
import type { ZOptionMeta } from './option-meta';
Expand All @@ -12,8 +12,8 @@ import type { SupportedZOptions } from './supported-options';
* Command line options parser.
*
* @internal
* @typeparam TCtx A type of option processing context required by parser.
* @typeparam TOption A type of option representation.
* @typeParam TCtx A type of option processing context required by parser.
* @typeParam TOption A type of option representation.
*/
export class ZOptionsParser$<TOption extends ZOption, TCtx> {

Expand Down Expand Up @@ -77,7 +77,7 @@ export class ZOptionsParser$<TOption extends ZOption, TCtx> {
): Promise<TCtx> {
const allOptions = supportedZOptionsMap(
context,
arrayOfElements(this._config.options).concat(arrayOfElements(options)),
asArray(this._config.options).concat(asArray(options)),
);
const optionMeta = lazyValue(() => supportedZOptionsMeta(allOptions));
const optionClass = this.optionClass;
Expand Down Expand Up @@ -195,7 +195,7 @@ function supportedZOptionsMeta<TOption extends ZOption>(
help = meta;
}

const usage = Array.from(arrayOfElements(help.usage));
const usage = Array.from(asArray(help.usage));
const existing = result.get(canonicalKey);

if (existing) {
Expand Down
16 changes: 8 additions & 8 deletions src/options-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import type { SupportedZOptions } from './supported-options';
/**
* Command line options parser signature.
*
* @typeparam TOption A type of option representation.
* @typeparam TCtx A type of option processing context required by parser.
* @typeParam TOption A type of option representation.
* @typeParam TCtx A type of option processing context required by parser.
*/
export type ZOptionsParser<TOption extends ZOption, TCtx> =
/**
Expand All @@ -28,8 +28,8 @@ export namespace ZOptionsParser {
/**
* Command line options parser configuration.
*
* @typeparam TOption A type of option representation.
* @typeparam TCtx Option processing context required by parser.
* @typeParam TOption A type of option representation.
* @typeParam TCtx Option processing context required by parser.
*/
export interface Config<TOption extends ZOption, TCtx> {
/**
Expand Down Expand Up @@ -59,8 +59,8 @@ export namespace ZOptionsParser {
/**
* Additional options for command line options parser.
*
* @typeparam TOption A type of option representation.
* @typeparam TCtx A type of option processing context required by parser.
* @typeParam TOption A type of option representation.
* @typeParam TCtx A type of option processing context required by parser.
*/
export interface Opts<TOption extends ZOption = ZOption, TCtx = unknown> {
/**
Expand All @@ -78,8 +78,8 @@ export namespace ZOptionsParser {
/**
* Builds custom command line options parser.
*
* @typeparam TOption A type of option representation.
* @typeparam TCtx A type of option processing context required by parser.
* @typeParam TOption A type of option representation.
* @typeParam TCtx A type of option processing context required by parser.
* @param config - Parser configuration.
*
* @returns New options parser.
Expand Down
12 changes: 6 additions & 6 deletions src/supported-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import type { ZOptionReader } from './option-reader';
* This is either a {@link SupportedZOptions.Map map of option readers}, its {@link SupportedZOptions.Provider provider
* function}, or an array of the above. Multiple readers may be specified per option key with the latter.
*
* @typeparam TOption A type of option representation.
* @typeparam TCtx A type of option processing context required by parser.
* @typeParam TOption A type of option representation.
* @typeParam TCtx A type of option processing context required by parser.
*/
export type SupportedZOptions<TOption extends ZOption = ZOption, TCtx = unknown> =
| SupportedZOptions.Map<TOption>
Expand All @@ -20,8 +20,8 @@ export namespace SupportedZOptions {
/**
* A map of {@link ZOptionReader readers} corresponding to option keys or their wildcards.
*
* @typeparam TCtx A type of option processing context required by parser.
* @typeparam TOption A type of option representation.
* @typeParam TCtx A type of option processing context required by parser.
* @typeParam TOption A type of option representation.
*/
export interface Map<TOption extends ZOption = ZOption> {
/**
Expand Down Expand Up @@ -72,8 +72,8 @@ export namespace SupportedZOptions {
*
* The provider is called at most once per {@link ZOptionsParser parser call}.
*
* @typeparam TCtx A type of option processing context required by parser.
* @typeparam TOption A type of option representation.
* @typeParam TCtx A type of option processing context required by parser.
* @typeParam TOption A type of option representation.
*/
export type Provider<TOption extends ZOption = ZOption, TCtx = unknown> =
/**
Expand Down

0 comments on commit 84a1990

Please sign in to comment.