decline-ts
Version:
Composable command-line parser for TypeScript - a (partial) porting of Scala decline using fp-ts
24 lines (23 loc) • 1.06 kB
TypeScript
import { either } from 'fp-ts';
import { Either } from 'fp-ts/Either';
import { Help } from './Help';
import { Opts } from './Opts';
import { ValidatedNea } from './ValidatedNea';
export declare type Command<A> = {
readonly _tag: 'Command';
readonly name: string;
readonly header: string;
readonly opts: Opts<A>;
};
export declare function Command({ name, header }: Command.Args): <A>(opts: Opts<A>) => Command<A>;
export declare namespace Command {
type Args = {
readonly name: string;
readonly header: string;
};
type TypeOf<C> = C extends Command<infer A> ? A : never;
const parseHelp: <A>(args: ReadonlyArray<string>) => (cmd: Command<A>) => either.Either<Help, A>;
const parse: <A>(args: ReadonlyArray<string>) => (cmd: Command<A>) => either.Either<string, A>;
const mapValidated: <A, B>(f: (a: A) => either.Either<import("fp-ts/lib/ReadonlyNonEmptyArray").ReadonlyNonEmptyArray<string>, B>) => (cmd: Command<A>) => Command<B>;
const map: <A, B>(f: (a: A) => B) => (cmd: Command<A>) => Command<B>;
}