-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod.ts
More file actions
111 lines (105 loc) · 2.31 KB
/
Copy pathmod.ts
File metadata and controls
111 lines (105 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/**
* Args-based CLI argument parser for Deno
*
* A powerful, type-safe command line argument parser using decorators and inheritance.
*
* @example Basic usage
* ```ts
* import { Args, cli, opt } from "./mod.ts";
*
* @cli({ name: "calculator", description: "A simple calculator" })
* class Calculator extends Args {
* @opt({ description: "First number", type: "number", required: true })
* a!: number;
*
* @opt({ description: "Second number", type: "number", required: true })
* b!: number;
*
* @opt({ description: "Operation to perform" })
* operation = "add";
* }
*
* const args = Calculator.parse(["--a", "10", "--b", "5"]);
* console.log(`${args.a} ${args.operation} ${args.b} = ${args.a + args.b}`);
* ```
*
* @example With subcommands
* ```ts
* import { Args, cli, command, opt, subCommand } from "./mod.ts";
*
* @command
* class ServeCommand {
* @opt({ description: "Port to serve on" })
* port = 3000;
* }
*
* @cli({ name: "myapp", description: "My application" })
* class MyApp extends Args {
* @subCommand(ServeCommand)
* serve?: ServeCommand;
* }
*
* const args = MyApp.parse(["serve", "--port", "8080"]);
* if (args.serve) {
* console.log(args.serve.port); // 8080 - Perfect type safety!
* }
* ```
*/
// Export the core Args base class and CLI decorator
export { Args, cli } from "./src/index.ts";
// Export all decorator functions
export {
addValidator,
arg,
command,
opt,
subCommand,
validate,
} from "./src/decorators.ts";
// Export validation functions
export {
arrayLength,
custom,
integer,
length,
max,
min,
oneOf,
pattern,
range,
validateValue,
} from "./src/validation.ts";
// Export types
export type {
ArgOptions,
ArgumentMetadata,
CollectionOptions,
CommandInstance,
CommandOptions,
CommonOptions,
DecoratorContext,
OptDef,
OptOptions,
ParseOptions,
ParseResult,
PositionalDef,
PositionalDef as ArgumentDef,
PropertyMetadata,
SubCommand,
SubCommandOptions,
SupportedType,
Validator,
} from "./src/index.ts";
// Export error handling utilities
export {
captureHelpText,
ErrorHandlers,
ErrorMessages,
handleHelpDisplay,
handleParsingError,
isParseError,
ParseError,
type ParseErrorType,
} from "./src/error-handling.ts";
// Export help generation
export { printHelp } from "./src/help.ts";