UNPKG

1.64 kBTypeScriptView Raw
1/**
2 * Cast To Type
3 * : Loosely tries to cast numbers and booleans.
4 *
5 * @param val the value to be cast.
6 */
7export declare function castToType(val: any): any;
8/**
9 * Flags To Array
10 * : Convert flag object to array.
11 *
12 * @param flags object containing flags.
13 */
14export declare function flagsToArray(flags: any): any[];
15/**
16 * Split Args
17 * : Splits string of command arguments honoring quotes.
18 *
19 * @param str the string representing arguments.
20 */
21export declare function splitArgs(str: string | any[]): any[];
22/**
23 * Normalize
24 * : Spreads multi flag arguments and breaks arguments usign = sign.
25 *
26 * @example
27 * -am: returns -a, -m.
28 * --flag=value: returns --flag, value.
29 *
30 * @param args arguments to be normalized.
31 */
32export declare function normalizeArgs(args: any, exclude?: any): any;
33/**
34 * Filter Args
35 * : Filters an array of arguments by exclusion list.
36 *
37 * @param args the arguments to be filtered.
38 * @param exclude the arguments to be excluded.
39 */
40export declare function filterArgs(args: any, exclude: any): any;
41/**
42 * Merge Args
43 * : Merges two sets of command arguments.
44 *
45 * @param def array of default args.
46 * @param args array of new args.
47 */
48export declare function mergeArgs(def: any, args: any, exclude?: any): any;
49/**
50 * Parse
51 * : Parses command arguments.
52 *
53 * @param args the arguments to be parsed if null uses process.argv.slice(2)
54 * @param exclude any flags or commands that should be excluded.
55 */
56export declare function parse(args?: any, exclude?: any): {
57 command: any;
58 commands: any[];
59 cmd: any;
60 cmds: any[];
61 flags: {};
62 source: string[];
63 normalized: any;
64};