1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 |
|
7 | const properties_1 = require("./models/properties");
|
8 | const properties_2 = require("./models/properties");
|
9 | const javaUtil_1 = require("./java/javaUtil");
|
10 | const StringBuilder_1 = __importDefault(require("./java/StringBuilder"));
|
11 | class CliOption {
|
12 | constructor(opt, description, type = properties_2.StringProperty.TYPE, short, enumValues, required) {
|
13 | this.opt = opt;
|
14 | this.description = description;
|
15 | this.type = type;
|
16 | }
|
17 | static newBoolean(opt, description) {
|
18 | return new CliOption(opt, description, properties_1.BooleanProperty.TYPE).defaultValue('false');
|
19 | }
|
20 | static newString(opt, description) {
|
21 | return new CliOption(opt, description, properties_2.StringProperty.TYPE);
|
22 | }
|
23 | getOpt() {
|
24 | return this.opt;
|
25 | }
|
26 | getDescription() {
|
27 | return this.description;
|
28 | }
|
29 | setDescription(description) {
|
30 | this.description = description;
|
31 | }
|
32 | getType() {
|
33 | return this.type;
|
34 | }
|
35 | setType(type) {
|
36 | this.type = type;
|
37 | }
|
38 | getDefault() {
|
39 | return this.__defaultValue;
|
40 | }
|
41 | setDefault(defaultValue) {
|
42 | this.__defaultValue = defaultValue;
|
43 | }
|
44 | defaultValue(defaultValue) {
|
45 | this.__defaultValue = defaultValue;
|
46 | return this;
|
47 | }
|
48 | addEnum(value, description) {
|
49 | if (this.enumValues == null) {
|
50 | this.enumValues = javaUtil_1.newHashMap();
|
51 | }
|
52 | if (!this.enumValues.containsKey(value)) {
|
53 | this.enumValues.put(value, description);
|
54 | }
|
55 | return this;
|
56 | }
|
57 | getEnum() {
|
58 | return this.enumValues;
|
59 | }
|
60 | setEnum(enumValues) {
|
61 | this.enumValues = enumValues;
|
62 | }
|
63 | getOptionHelp() {
|
64 | const sb = StringBuilder_1.default(this.description);
|
65 | if (this.__defaultValue != null) {
|
66 | sb.append(' (Default: ')
|
67 | .append(this.__defaultValue)
|
68 | .append(')');
|
69 | }
|
70 | if (this.enumValues != null) {
|
71 | for (const [key, value] of this.enumValues) {
|
72 | sb.append('\n ')
|
73 | .append(key)
|
74 | .append(' - ')
|
75 | .append(value);
|
76 | }
|
77 | }
|
78 | return sb.toString();
|
79 | }
|
80 | }
|
81 | exports.default = CliOption;
|
82 |
|
\ | No newline at end of file |