cli-api 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -25
- package/dist/index.d.mts +439 -0
- package/dist/index.mjs +3 -0
- package/dist/interfaces-CfKTHP7y.mjs +510 -0
- package/dist/run-DEkBUX4b.mjs +1374 -0
- package/package.json +37 -37
- package/.hgignore +0 -12
- package/Makefile +0 -14
- package/babel.config.json +0 -33
- package/dist/cjs/index.js +0 -588
- package/dist/cjs/index.js.map +0 -1
- package/dist/es/index.mjs +0 -578
- package/dist/es/index.mjs.map +0 -1
- package/dist/types/app-help.d.ts +0 -3
- package/dist/types/commands/command-help.d.ts +0 -2
- package/dist/types/commands/version.d.ts +0 -2
- package/dist/types/constants.d.ts +0 -4
- package/dist/types/index.d.ts +0 -3
- package/dist/types/interfaces.d.ts +0 -79
- package/dist/types/options.d.ts +0 -7
- package/dist/types/print-command-help.d.ts +0 -2
- package/dist/types/run.d.ts +0 -2
- package/dist/types/utils.d.ts +0 -17
- package/rollup.config.js +0 -44
- package/tsconfig.json +0 -32
package/dist/types/index.d.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
export interface Command {
|
|
2
|
-
name: string;
|
|
3
|
-
alias?: string | string[];
|
|
4
|
-
description?: string;
|
|
5
|
-
longDescription?: string;
|
|
6
|
-
flags?: Flag[];
|
|
7
|
-
options?: Option[];
|
|
8
|
-
arguments?: Argument[];
|
|
9
|
-
/**
|
|
10
|
-
* Executed when the command matches.
|
|
11
|
-
*
|
|
12
|
-
* @param options Named arguments, options, and flags.
|
|
13
|
-
* @param args Positional arguments.
|
|
14
|
-
* @param app Entire app config.
|
|
15
|
-
*/
|
|
16
|
-
execute(options: Record<string, any>, args: string[], app: App): Promise<number | void>;
|
|
17
|
-
}
|
|
18
|
-
export declare enum OptType {
|
|
19
|
-
STRING = 0,
|
|
20
|
-
BOOL = 1,
|
|
21
|
-
INT = 2,
|
|
22
|
-
FLOAT = 3,
|
|
23
|
-
/** A string, truncated and converted to lowercase. */
|
|
24
|
-
ENUM = 4,
|
|
25
|
-
/** File must be readable. Single dash will be converted to STDIN. */
|
|
26
|
-
INPUT_FILE = 5,
|
|
27
|
-
/** Directory must be readable. */
|
|
28
|
-
INPUT_DIRECTORY = 6,
|
|
29
|
-
/** File's directory must exist and be writeable. Single dash will be converted to STDOUT. */
|
|
30
|
-
OUTPUT_FILE = 7,
|
|
31
|
-
OUTPUT_DIRECTORY = 8,
|
|
32
|
-
/** An empty or non-existent directory. */
|
|
33
|
-
EMPTY_DIRECTORY = 9
|
|
34
|
-
}
|
|
35
|
-
interface ArgumentOrOptionOrFlag {
|
|
36
|
-
/** Name of the option to display in help. */
|
|
37
|
-
name: string;
|
|
38
|
-
/** Alternative name for this option. */
|
|
39
|
-
alias?: string | string[];
|
|
40
|
-
/** Description of the option. */
|
|
41
|
-
description?: string;
|
|
42
|
-
/** Default value if not provided. */
|
|
43
|
-
defaultValue?: any | ((value: string) => any);
|
|
44
|
-
/** Default value to display in help. */
|
|
45
|
-
defaultValueText?: string;
|
|
46
|
-
/** Property name to use in `execute()` options. */
|
|
47
|
-
key?: string;
|
|
48
|
-
}
|
|
49
|
-
export declare type AnyOptType = OptType | string[];
|
|
50
|
-
export interface ArgumentOrOption extends ArgumentOrOptionOrFlag {
|
|
51
|
-
/** Type to coerce the option value to. */
|
|
52
|
-
type?: AnyOptType;
|
|
53
|
-
/** Option is repeatable by specifying the flag again. Value will be an array. */
|
|
54
|
-
repeatable?: boolean;
|
|
55
|
-
/** Option is required. */
|
|
56
|
-
required?: boolean;
|
|
57
|
-
}
|
|
58
|
-
/** Boolean flag. */
|
|
59
|
-
export interface Flag extends ArgumentOrOptionOrFlag, OptionOrFlag {
|
|
60
|
-
}
|
|
61
|
-
/** Positional argument. */
|
|
62
|
-
export interface Argument extends ArgumentOrOption {
|
|
63
|
-
}
|
|
64
|
-
interface OptionOrFlag {
|
|
65
|
-
valueNotRequired?: boolean;
|
|
66
|
-
}
|
|
67
|
-
/** Option with value. */
|
|
68
|
-
export interface Option extends ArgumentOrOption, OptionOrFlag {
|
|
69
|
-
/** Placeholder value to use in help. */
|
|
70
|
-
valuePlaceholder?: string;
|
|
71
|
-
}
|
|
72
|
-
export interface App {
|
|
73
|
-
name: string;
|
|
74
|
-
argv0?: string;
|
|
75
|
-
version?: string;
|
|
76
|
-
commands: Command[];
|
|
77
|
-
globalOptions?: Option[];
|
|
78
|
-
}
|
|
79
|
-
export {};
|
package/dist/types/options.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { App, Command, Option } from './interfaces';
|
|
2
|
-
export declare function formatOption(opt: Option): [string, string];
|
|
3
|
-
export declare function getValuePlaceholder(opt: Option): string;
|
|
4
|
-
export declare function getOptions(cmd: Command): Option[];
|
|
5
|
-
export declare function parseArgs(cmd: Command, argv: string[]): [any[], Record<string, any>];
|
|
6
|
-
export declare function getOptName(opt: Option): string;
|
|
7
|
-
export declare function getCommand(name: string, app: App): Command;
|
package/dist/types/run.d.ts
DELETED
package/dist/types/utils.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { App } from './interfaces';
|
|
3
|
-
import FileSys from 'fs';
|
|
4
|
-
export declare const print: {
|
|
5
|
-
(buffer: string | Uint8Array, cb?: ((err?: Error | undefined) => void) | undefined): boolean;
|
|
6
|
-
(str: string | Uint8Array, encoding?: string | undefined, cb?: ((err?: Error | undefined) => void) | undefined): boolean;
|
|
7
|
-
};
|
|
8
|
-
export declare const printLn: (message?: any, ...optionalParams: any[]) => void;
|
|
9
|
-
export declare function abort(message: string, code?: number): never;
|
|
10
|
-
export declare function toArray<T>(x: T | T[]): readonly T[];
|
|
11
|
-
export declare function resolve<T>(x: any): T;
|
|
12
|
-
export declare function toBool(str: string | boolean): boolean;
|
|
13
|
-
export declare function space(len: number, str?: string): string;
|
|
14
|
-
export declare function getProcName(app: App): string;
|
|
15
|
-
export declare function includes(needle: string, haystack: string | string[] | undefined): boolean;
|
|
16
|
-
export declare function statSync(path: string): FileSys.Stats | null;
|
|
17
|
-
export declare function sortBy<T>(arr: T[], cmp: (x: T) => string): T[];
|
package/rollup.config.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import babel from '@rollup/plugin-babel';
|
|
2
|
-
import nodeResolve from '@rollup/plugin-node-resolve';
|
|
3
|
-
import nodeExternals from 'rollup-plugin-node-externals'
|
|
4
|
-
import * as tsconfig from './tsconfig.json';
|
|
5
|
-
import * as pkg from './package.json'
|
|
6
|
-
import json from '@rollup/plugin-json';
|
|
7
|
-
const extensions = ['.ts'];
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
input: tsconfig.files,
|
|
11
|
-
plugins: [
|
|
12
|
-
nodeResolve({
|
|
13
|
-
extensions,
|
|
14
|
-
}),
|
|
15
|
-
nodeExternals({
|
|
16
|
-
builtins: true,
|
|
17
|
-
deps: true,
|
|
18
|
-
devDeps: false,
|
|
19
|
-
peerDeps: true,
|
|
20
|
-
optDeps: true,
|
|
21
|
-
}),
|
|
22
|
-
json(),
|
|
23
|
-
// TODO: change to typescript2 like node-mysql3c
|
|
24
|
-
babel({
|
|
25
|
-
exclude: 'node_modules/**',
|
|
26
|
-
extensions,
|
|
27
|
-
comments: false,
|
|
28
|
-
babelHelpers: 'bundled',
|
|
29
|
-
}),
|
|
30
|
-
],
|
|
31
|
-
output: [
|
|
32
|
-
{
|
|
33
|
-
file: pkg.main,
|
|
34
|
-
format: 'cjs',
|
|
35
|
-
sourcemap: true,
|
|
36
|
-
exports: 'named',
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
file: pkg.module,
|
|
40
|
-
format: 'es',
|
|
41
|
-
sourcemap: true,
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"strict": true,
|
|
4
|
-
"importHelpers": false,
|
|
5
|
-
"inlineSources": true,
|
|
6
|
-
"noEmitOnError": true,
|
|
7
|
-
"pretty": true,
|
|
8
|
-
"module": "commonjs",
|
|
9
|
-
"noImplicitAny": true,
|
|
10
|
-
"suppressImplicitAnyIndexErrors": false,
|
|
11
|
-
"removeComments": false,
|
|
12
|
-
"preserveConstEnums": false,
|
|
13
|
-
"sourceMap": true,
|
|
14
|
-
"lib": ["esnext"],
|
|
15
|
-
"skipLibCheck": false,
|
|
16
|
-
"outDir": "dist/types",
|
|
17
|
-
"emitDeclarationOnly": true,
|
|
18
|
-
"target": "esnext",
|
|
19
|
-
"declaration": true,
|
|
20
|
-
"resolveJsonModule": true,
|
|
21
|
-
"esModuleInterop": true,
|
|
22
|
-
"moduleResolution": "node",
|
|
23
|
-
"isolatedModules": true,
|
|
24
|
-
"allowSyntheticDefaultImports": true
|
|
25
|
-
},
|
|
26
|
-
"files": [
|
|
27
|
-
"src/index.ts"
|
|
28
|
-
],
|
|
29
|
-
"include": [
|
|
30
|
-
"src/**/*.d.ts"
|
|
31
|
-
]
|
|
32
|
-
}
|