/** * Core bargs API using parser combinator pattern. * * Provides `bargs()` for building CLIs with a fluent API, plus combinator * functions like `pipe()`, `map()`, and `handle()`. * * @packageDocumentation */ import type { CamelCaseKeys, CliBuilder, Command, CreateOptions, HandlerFn, Parser, ParseResult } from "./types.js"; /** * Transform fn type - can be sync or async. * * @group Combinators * @knipignore */ export type TransformFn = (result: ParseResult) => ParseResult | Promise>; /** * Create a command with a handler (terminal in the pipeline). * * @group Combinators */ export declare function handle(fn: HandlerFn): (parser: Parser) => Command; export declare function handle(parser: Parser, fn: HandlerFn): Command; /** * Transform parse result in the pipeline. * * @group Combinators */ export declare function map(fn: TransformFn): (parser: Parser) => Parser; export declare function map(parser: Parser, fn: TransformFn): Parser; /** * Merge multiple parsers into one. * * Combines options and positionals from all parsers. Later parsers' options * override earlier ones if there are conflicts. * * @example * * ```typescript * const parser = merge( * opt.options({ verbose: opt.boolean() }), * pos.positionals(pos.string({ name: 'file', required: true })), * ); * ``` * * @group Combinators */ export declare function merge(p1: Parser, p2: Parser): Parser; export declare function merge(p1: Parser, p2: Parser, p3: Parser): Parser; export declare function merge(p1: Parser, p2: Parser, p3: Parser, p4: Parser): Parser; /** * Transform for use with `map()` that converts kebab-case option keys to * camelCase. * * @example * * ```typescript * import { bargs, opt, map, camelCaseValues } from '@boneskull/bargs'; * * const { values } = await bargs('my-cli') * .globals( * map(opt.options({ 'output-dir': opt.string() }), camelCaseValues), * ) * .parseAsync(); * * console.log(values.outputDir); // camelCased! * ``` * * @function * @group Transforms */ export declare const camelCaseValues: (result: ParseResult) => ParseResult, P>; /** * Create a new CLI. * * @example * * ```typescript * const cli = await bargs('my-app', { version: '1.0.0' }) * .globals( * map(opt.options({ verbose: opt.boolean() }), ({ values }) => ({ * values: { ...values, ts: Date.now() }, * positionals: [] as const, * })), * ) * .command( * 'greet', * pos.positionals(pos.string({ name: 'name', required: true })), * ({ positionals }) => console.log(`Hello, ${positionals[0]}!`), * ) * .parseAsync(); * ``` * * @function * @group Core API */ export declare const bargs: { (name: string, options?: CreateOptions): CliBuilder, readonly []>; /** * @ignore * @deprecated */ create: /*elided*/ any; }; //# sourceMappingURL=bargs.d.ts.map