@duplojs/server 0.1.0-beta.5 → 0.1.0-beta.7
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/dist/command/error.cjs +80 -51
- package/dist/command/error.mjs +80 -51
- package/dist/command/help.cjs +17 -26
- package/dist/command/help.mjs +17 -26
- package/package.json +3 -3
package/dist/command/error.cjs
CHANGED
|
@@ -98,73 +98,102 @@ function createError(commandName) {
|
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
function interpretDataStructureError(error, dataStructureErrorInterpreter) {
|
|
101
|
-
return _duplojs_lang_common.pipe(dataStructureErrorInterpreter(error), _duplojs_lang_array.map(({ interpretedMessage, path }) => _duplojs_lang_printer.
|
|
102
|
-
_duplojs_lang_printer.indent(1),
|
|
101
|
+
return _duplojs_lang_common.pipe(dataStructureErrorInterpreter(error), _duplojs_lang_array.map(({ interpretedMessage, path }) => _duplojs_lang_printer.renderLine([
|
|
103
102
|
"↳ ",
|
|
104
103
|
_duplojs_lang_printer.colorizedBold(path || "<value>", "cyan"),
|
|
105
104
|
" : ",
|
|
106
105
|
_duplojs_lang_printer.colorizedBold(interpretedMessage.subSource ?? interpretedMessage.interpretedSubSource ?? interpretedMessage.source ?? interpretedMessage.interpretedSource ?? "unknown data structure error.", "red")
|
|
107
|
-
],
|
|
106
|
+
], {
|
|
107
|
+
joinCharacter: "",
|
|
108
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
109
|
+
indentLevel: 1
|
|
110
|
+
})));
|
|
108
111
|
}
|
|
109
112
|
function interpretErrorIssues(issues, dataStructureErrorInterpreter) {
|
|
110
113
|
return _duplojs_lang_printer.renderParagraph([_duplojs_lang_array.map(issues, _duplojs_lang_pattern.matchWithTaggedObject({
|
|
111
|
-
UnknownOptionIssue: ({ optionTokens }) => [_duplojs_lang_printer.
|
|
112
|
-
|
|
113
|
-
_duplojs_lang_printer.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
_duplojs_lang_printer.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
_duplojs_lang_printer.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
_duplojs_lang_printer.
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
114
|
+
UnknownOptionIssue: ({ optionTokens }) => [_duplojs_lang_printer.renderLine([_duplojs_lang_printer.colorizedBold("OPTION: ", "blue"), _duplojs_lang_string.join(optionTokens, ", ")], {
|
|
115
|
+
joinCharacter: "",
|
|
116
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
117
|
+
indentLevel: 1
|
|
118
|
+
}), _duplojs_lang_printer.renderLine(["↳ Unknown Option"], {
|
|
119
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
120
|
+
indentLevel: 1
|
|
121
|
+
})],
|
|
122
|
+
UnknownSubCommandIssue: ({ subCommandName }) => [_duplojs_lang_printer.renderLine([_duplojs_lang_printer.colorizedBold("SUB-COMMAND: ", "cyan"), subCommandName], {
|
|
123
|
+
joinCharacter: "",
|
|
124
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
125
|
+
indentLevel: 1
|
|
126
|
+
}), _duplojs_lang_printer.renderLine(["↳ Unknown Sub-command"], {
|
|
127
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
128
|
+
indentLevel: 1
|
|
129
|
+
})],
|
|
130
|
+
DataStructureArgumentIssue: ({ argumentName, dataStructureError }) => [_duplojs_lang_printer.renderLine([_duplojs_lang_printer.colorizedBold("ARGUMENT: ", "magenta"), `--${argumentName}`], {
|
|
131
|
+
joinCharacter: "",
|
|
132
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
133
|
+
indentLevel: 1
|
|
134
|
+
}), interpretDataStructureError(dataStructureError, dataStructureErrorInterpreter)],
|
|
135
|
+
RequiredArgumentIssue: ({ argumentName }) => [_duplojs_lang_printer.renderLine([_duplojs_lang_printer.colorizedBold("ARGUMENT: ", "magenta"), argumentName], {
|
|
136
|
+
joinCharacter: "",
|
|
137
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
138
|
+
indentLevel: 1
|
|
139
|
+
}), _duplojs_lang_printer.renderLine(["↳ Missing Argument"], {
|
|
140
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
141
|
+
indentLevel: 1
|
|
142
|
+
})],
|
|
143
|
+
DataStructureOptionIssue: ({ optionName, dataStructureError }) => [_duplojs_lang_printer.renderLine([_duplojs_lang_printer.colorizedBold("OPTION: ", "blue"), `--${optionName}`], {
|
|
144
|
+
joinCharacter: "",
|
|
145
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
146
|
+
indentLevel: 1
|
|
147
|
+
}), interpretDataStructureError(dataStructureError, dataStructureErrorInterpreter)],
|
|
148
|
+
RequiredOptionIssue: ({ optionName }) => [_duplojs_lang_printer.renderLine([_duplojs_lang_printer.colorizedBold("OPTION: ", "blue"), `--${optionName}`], {
|
|
149
|
+
joinCharacter: "",
|
|
150
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
151
|
+
indentLevel: 1
|
|
152
|
+
}), _duplojs_lang_printer.renderLine(["↳ Missing Option"], {
|
|
153
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
154
|
+
indentLevel: 1
|
|
155
|
+
})],
|
|
156
|
+
RequiredOptionValueIssue: ({ optionName }) => [_duplojs_lang_printer.renderLine([_duplojs_lang_printer.colorizedBold("OPTION: ", "blue"), `--${optionName}`], {
|
|
157
|
+
joinCharacter: "",
|
|
158
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
159
|
+
indentLevel: 1
|
|
160
|
+
}), _duplojs_lang_printer.renderLine(["↳ Missing Option Value"], {
|
|
161
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
162
|
+
indentLevel: 1
|
|
163
|
+
})],
|
|
164
|
+
UnexpectedOptionValueIssue: ({ optionName }) => [_duplojs_lang_printer.renderLine([_duplojs_lang_printer.colorizedBold("OPTION: ", "blue"), `--${optionName}`], {
|
|
165
|
+
joinCharacter: "",
|
|
166
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
167
|
+
indentLevel: 1
|
|
168
|
+
}), _duplojs_lang_printer.renderLine(["↳ Unexpected Value At This Option"], {
|
|
169
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
170
|
+
indentLevel: 1
|
|
171
|
+
})],
|
|
172
|
+
TooMuchCommandArgumentIssue: ({ expect, receive }) => [_duplojs_lang_printer.renderLine([" Too Much Arguments"], {
|
|
173
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
174
|
+
indentLevel: 1
|
|
175
|
+
}), _duplojs_lang_printer.renderLine([` expect: ${expect} receive: ${receive}`], {
|
|
176
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
177
|
+
indentLevel: 1
|
|
178
|
+
})]
|
|
152
179
|
})), issues.length === 0 && "No issue found"]);
|
|
153
180
|
}
|
|
154
181
|
const defaultDataStructureErrorInterpreter = _duplojs_lang_dataStructure.createErrorInterpreter(require_defaultInterpreter.defaultErrorInterpreterDataStructureDictionary, require_defaultInterpreter.defaultErrorInterpreterCodecDictionary);
|
|
155
182
|
function interpretExecCommandError(error, dataStructureErrorInterpreter) {
|
|
156
|
-
return _duplojs_lang_printer.renderParagraph([
|
|
183
|
+
return _duplojs_lang_printer.renderParagraph([
|
|
157
184
|
_duplojs_lang_printer.colorizedBold("Command failed", "red"),
|
|
158
|
-
_duplojs_lang_printer.
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
185
|
+
_duplojs_lang_printer.renderLine([_duplojs_lang_printer.colorizedBold("COMMAND: ", "cyan"), _duplojs_lang_string.join(error.currentPath, " ")], {
|
|
186
|
+
joinCharacter: "",
|
|
187
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
188
|
+
indentLevel: 1
|
|
189
|
+
}),
|
|
190
|
+
interpretErrorIssues(error.issues, dataStructureErrorInterpreter ?? defaultDataStructureErrorInterpreter)
|
|
191
|
+
]);
|
|
163
192
|
}
|
|
164
193
|
function interpretExecOptionsError(error, dataStructureErrorInterpreter) {
|
|
165
194
|
return _duplojs_lang_printer.renderParagraph([
|
|
166
195
|
_duplojs_lang_printer.colorizedBold("Invalid options", "red"),
|
|
167
|
-
|
|
196
|
+
["", ""],
|
|
168
197
|
interpretErrorIssues(error.issues, dataStructureErrorInterpreter ?? defaultDataStructureErrorInterpreter)
|
|
169
198
|
]);
|
|
170
199
|
}
|
package/dist/command/error.mjs
CHANGED
|
@@ -90,73 +90,102 @@ function createError(commandName) {
|
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
92
|
function interpretDataStructureError(error, dataStructureErrorInterpreter) {
|
|
93
|
-
return DCommon.pipe(dataStructureErrorInterpreter(error), DArray.map(({ interpretedMessage, path }) => DPrinter.
|
|
94
|
-
DPrinter.indent(1),
|
|
93
|
+
return DCommon.pipe(dataStructureErrorInterpreter(error), DArray.map(({ interpretedMessage, path }) => DPrinter.renderLine([
|
|
95
94
|
"↳ ",
|
|
96
95
|
DPrinter.colorizedBold(path || "<value>", "cyan"),
|
|
97
96
|
" : ",
|
|
98
97
|
DPrinter.colorizedBold(interpretedMessage.subSource ?? interpretedMessage.interpretedSubSource ?? interpretedMessage.source ?? interpretedMessage.interpretedSource ?? "unknown data structure error.", "red")
|
|
99
|
-
],
|
|
98
|
+
], {
|
|
99
|
+
joinCharacter: "",
|
|
100
|
+
indent: DPrinter.Indent.tab,
|
|
101
|
+
indentLevel: 1
|
|
102
|
+
})));
|
|
100
103
|
}
|
|
101
104
|
function interpretErrorIssues(issues, dataStructureErrorInterpreter) {
|
|
102
105
|
return DPrinter.renderParagraph([DArray.map(issues, DPattern.matchWithTaggedObject({
|
|
103
|
-
UnknownOptionIssue: ({ optionTokens }) => [DPrinter.
|
|
104
|
-
|
|
105
|
-
DPrinter.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
DPrinter.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
DPrinter.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
DPrinter.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
106
|
+
UnknownOptionIssue: ({ optionTokens }) => [DPrinter.renderLine([DPrinter.colorizedBold("OPTION: ", "blue"), DString.join(optionTokens, ", ")], {
|
|
107
|
+
joinCharacter: "",
|
|
108
|
+
indent: DPrinter.Indent.tab,
|
|
109
|
+
indentLevel: 1
|
|
110
|
+
}), DPrinter.renderLine(["↳ Unknown Option"], {
|
|
111
|
+
indent: DPrinter.Indent.tab,
|
|
112
|
+
indentLevel: 1
|
|
113
|
+
})],
|
|
114
|
+
UnknownSubCommandIssue: ({ subCommandName }) => [DPrinter.renderLine([DPrinter.colorizedBold("SUB-COMMAND: ", "cyan"), subCommandName], {
|
|
115
|
+
joinCharacter: "",
|
|
116
|
+
indent: DPrinter.Indent.tab,
|
|
117
|
+
indentLevel: 1
|
|
118
|
+
}), DPrinter.renderLine(["↳ Unknown Sub-command"], {
|
|
119
|
+
indent: DPrinter.Indent.tab,
|
|
120
|
+
indentLevel: 1
|
|
121
|
+
})],
|
|
122
|
+
DataStructureArgumentIssue: ({ argumentName, dataStructureError }) => [DPrinter.renderLine([DPrinter.colorizedBold("ARGUMENT: ", "magenta"), `--${argumentName}`], {
|
|
123
|
+
joinCharacter: "",
|
|
124
|
+
indent: DPrinter.Indent.tab,
|
|
125
|
+
indentLevel: 1
|
|
126
|
+
}), interpretDataStructureError(dataStructureError, dataStructureErrorInterpreter)],
|
|
127
|
+
RequiredArgumentIssue: ({ argumentName }) => [DPrinter.renderLine([DPrinter.colorizedBold("ARGUMENT: ", "magenta"), argumentName], {
|
|
128
|
+
joinCharacter: "",
|
|
129
|
+
indent: DPrinter.Indent.tab,
|
|
130
|
+
indentLevel: 1
|
|
131
|
+
}), DPrinter.renderLine(["↳ Missing Argument"], {
|
|
132
|
+
indent: DPrinter.Indent.tab,
|
|
133
|
+
indentLevel: 1
|
|
134
|
+
})],
|
|
135
|
+
DataStructureOptionIssue: ({ optionName, dataStructureError }) => [DPrinter.renderLine([DPrinter.colorizedBold("OPTION: ", "blue"), `--${optionName}`], {
|
|
136
|
+
joinCharacter: "",
|
|
137
|
+
indent: DPrinter.Indent.tab,
|
|
138
|
+
indentLevel: 1
|
|
139
|
+
}), interpretDataStructureError(dataStructureError, dataStructureErrorInterpreter)],
|
|
140
|
+
RequiredOptionIssue: ({ optionName }) => [DPrinter.renderLine([DPrinter.colorizedBold("OPTION: ", "blue"), `--${optionName}`], {
|
|
141
|
+
joinCharacter: "",
|
|
142
|
+
indent: DPrinter.Indent.tab,
|
|
143
|
+
indentLevel: 1
|
|
144
|
+
}), DPrinter.renderLine(["↳ Missing Option"], {
|
|
145
|
+
indent: DPrinter.Indent.tab,
|
|
146
|
+
indentLevel: 1
|
|
147
|
+
})],
|
|
148
|
+
RequiredOptionValueIssue: ({ optionName }) => [DPrinter.renderLine([DPrinter.colorizedBold("OPTION: ", "blue"), `--${optionName}`], {
|
|
149
|
+
joinCharacter: "",
|
|
150
|
+
indent: DPrinter.Indent.tab,
|
|
151
|
+
indentLevel: 1
|
|
152
|
+
}), DPrinter.renderLine(["↳ Missing Option Value"], {
|
|
153
|
+
indent: DPrinter.Indent.tab,
|
|
154
|
+
indentLevel: 1
|
|
155
|
+
})],
|
|
156
|
+
UnexpectedOptionValueIssue: ({ optionName }) => [DPrinter.renderLine([DPrinter.colorizedBold("OPTION: ", "blue"), `--${optionName}`], {
|
|
157
|
+
joinCharacter: "",
|
|
158
|
+
indent: DPrinter.Indent.tab,
|
|
159
|
+
indentLevel: 1
|
|
160
|
+
}), DPrinter.renderLine(["↳ Unexpected Value At This Option"], {
|
|
161
|
+
indent: DPrinter.Indent.tab,
|
|
162
|
+
indentLevel: 1
|
|
163
|
+
})],
|
|
164
|
+
TooMuchCommandArgumentIssue: ({ expect, receive }) => [DPrinter.renderLine([" Too Much Arguments"], {
|
|
165
|
+
indent: DPrinter.Indent.tab,
|
|
166
|
+
indentLevel: 1
|
|
167
|
+
}), DPrinter.renderLine([` expect: ${expect} receive: ${receive}`], {
|
|
168
|
+
indent: DPrinter.Indent.tab,
|
|
169
|
+
indentLevel: 1
|
|
170
|
+
})]
|
|
144
171
|
})), issues.length === 0 && "No issue found"]);
|
|
145
172
|
}
|
|
146
173
|
const defaultDataStructureErrorInterpreter = DDataStructure.createErrorInterpreter(defaultErrorInterpreterDataStructureDictionary, defaultErrorInterpreterCodecDictionary);
|
|
147
174
|
function interpretExecCommandError(error, dataStructureErrorInterpreter) {
|
|
148
|
-
return DPrinter.renderParagraph([
|
|
175
|
+
return DPrinter.renderParagraph([
|
|
149
176
|
DPrinter.colorizedBold("Command failed", "red"),
|
|
150
|
-
DPrinter.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
177
|
+
DPrinter.renderLine([DPrinter.colorizedBold("COMMAND: ", "cyan"), DString.join(error.currentPath, " ")], {
|
|
178
|
+
joinCharacter: "",
|
|
179
|
+
indent: DPrinter.Indent.tab,
|
|
180
|
+
indentLevel: 1
|
|
181
|
+
}),
|
|
182
|
+
interpretErrorIssues(error.issues, dataStructureErrorInterpreter ?? defaultDataStructureErrorInterpreter)
|
|
183
|
+
]);
|
|
155
184
|
}
|
|
156
185
|
function interpretExecOptionsError(error, dataStructureErrorInterpreter) {
|
|
157
186
|
return DPrinter.renderParagraph([
|
|
158
187
|
DPrinter.colorizedBold("Invalid options", "red"),
|
|
159
|
-
|
|
188
|
+
["", ""],
|
|
160
189
|
interpretErrorIssues(error.issues, dataStructureErrorInterpreter ?? defaultDataStructureErrorInterpreter)
|
|
161
190
|
]);
|
|
162
191
|
}
|
package/dist/command/help.cjs
CHANGED
|
@@ -30,8 +30,12 @@ const literal = (input) => _duplojs_lang_printer.colorized(input, "yellow");
|
|
|
30
30
|
const marker = (input) => _duplojs_lang_printer.colorized(input, "yellow");
|
|
31
31
|
const secondary = (input) => _duplojs_lang_printer.colorized(input, "gray");
|
|
32
32
|
const constraintLabel = (input) => _duplojs_lang_printer.colorized(input, "magenta");
|
|
33
|
-
function renderInline(input) {
|
|
34
|
-
return _duplojs_lang_printer.
|
|
33
|
+
function renderInline(input, depth = 0) {
|
|
34
|
+
return _duplojs_lang_printer.renderLine(input, {
|
|
35
|
+
joinCharacter: "",
|
|
36
|
+
indent: _duplojs_lang_printer.Indent.tab,
|
|
37
|
+
indentLevel: depth
|
|
38
|
+
});
|
|
35
39
|
}
|
|
36
40
|
function formatLiteral(value) {
|
|
37
41
|
if (typeof value === "string") return JSON.stringify(value);
|
|
@@ -159,14 +163,10 @@ function renderMetadata(help, markerValue) {
|
|
|
159
163
|
]);
|
|
160
164
|
}
|
|
161
165
|
function renderConstraintLines(constraints, depth) {
|
|
162
|
-
return _duplojs_lang_array.map(constraints, (constraint) => renderInline([
|
|
163
|
-
_duplojs_lang_printer.indent(depth),
|
|
164
|
-
secondary("↳ "),
|
|
165
|
-
constraint
|
|
166
|
-
]));
|
|
166
|
+
return _duplojs_lang_array.map(constraints, (constraint) => renderInline([secondary("↳ "), constraint], depth));
|
|
167
167
|
}
|
|
168
168
|
function renderDescriptionLine(description, depth) {
|
|
169
|
-
return description ? renderInline([
|
|
169
|
+
return description ? renderInline([secondary(description)], depth) : null;
|
|
170
170
|
}
|
|
171
171
|
function renderUsage(command) {
|
|
172
172
|
const args = command.subject?.type === "argument" ? _duplojs_lang_array.map(command.subject.args, (argument) => argument.optional ? `[${argument.name}]` : `<${argument.name}>`) : command.subject?.type === "subCommand" ? ["<command>"] : [];
|
|
@@ -193,48 +193,39 @@ function renderOptionDetails(option, depth) {
|
|
|
193
193
|
if (require_simple.simpleOptionKind.has(option) || require_array.arrayOptionKind.has(option)) {
|
|
194
194
|
const help = renderDataStructure(option.dataStructure);
|
|
195
195
|
return _duplojs_lang_array.filter([
|
|
196
|
-
renderInline([
|
|
196
|
+
renderInline([renderMetadata(help, option.required ? "required" : "optional")], depth),
|
|
197
197
|
...renderConstraintLines(help.constraints, depth),
|
|
198
198
|
renderDescriptionLine(option.description, depth)
|
|
199
199
|
], _duplojs_lang_common.truthy);
|
|
200
200
|
}
|
|
201
|
-
if (require_boolean.booleanOptionKind.has(option)) return _duplojs_lang_array.filter([renderInline([
|
|
201
|
+
if (require_boolean.booleanOptionKind.has(option)) return _duplojs_lang_array.filter([renderInline([typeLabel("boolean")], depth), renderDescriptionLine(option.description, depth)], _duplojs_lang_common.truthy);
|
|
202
202
|
return _duplojs_lang_array.filter([renderDescriptionLine(option.description, depth)], _duplojs_lang_common.truthy);
|
|
203
203
|
}
|
|
204
204
|
function renderOptionsHelp(options, depth) {
|
|
205
|
-
return _duplojs_lang_printer.renderParagraph([renderInline([
|
|
205
|
+
return _duplojs_lang_printer.renderParagraph([renderInline([section("OPTIONS", "magenta")], depth), _duplojs_lang_array.map(options, (option) => _duplojs_lang_printer.renderParagraph([renderInline([renderOptionSignature(option)], depth + 1), renderOptionDetails(option, depth + 2)]))]);
|
|
206
206
|
}
|
|
207
207
|
function renderArgumentsHelp(args, depth) {
|
|
208
|
-
return _duplojs_lang_printer.renderParagraph([renderInline([
|
|
208
|
+
return _duplojs_lang_printer.renderParagraph([renderInline([section("ARGUMENTS", "cyan")], depth), _duplojs_lang_array.map(args, (argument) => {
|
|
209
209
|
const help = renderDataStructure(argument.dataStructure);
|
|
210
210
|
return _duplojs_lang_printer.renderParagraph([
|
|
211
|
-
renderInline([
|
|
212
|
-
_duplojs_lang_printer.indent(depth + 1),
|
|
213
|
-
name(argument.name.padEnd(12)),
|
|
214
|
-
renderMetadata(help, argument.optional ? "optional" : "required")
|
|
215
|
-
]),
|
|
211
|
+
renderInline([name(argument.name.padEnd(12)), renderMetadata(help, argument.optional ? "optional" : "required")], depth + 1),
|
|
216
212
|
renderConstraintLines(help.constraints, depth + 2),
|
|
217
213
|
renderDescriptionLine(argument.description, depth + 2)
|
|
218
214
|
]);
|
|
219
215
|
})]);
|
|
220
216
|
}
|
|
221
217
|
function renderSubCommandsHelp(commands, depth) {
|
|
222
|
-
return _duplojs_lang_printer.renderParagraph([renderInline([
|
|
223
|
-
_duplojs_lang_printer.indent(depth + 1),
|
|
224
|
-
name(command.name.padEnd(16)),
|
|
225
|
-
command.description ? secondary(command.description) : null
|
|
226
|
-
]))]);
|
|
218
|
+
return _duplojs_lang_printer.renderParagraph([renderInline([section("COMMANDS", "green")], depth), _duplojs_lang_array.map(commands, (command) => renderInline([name(command.name.padEnd(16)), command.description ? secondary(command.description) : null], depth + 1))]);
|
|
227
219
|
}
|
|
228
220
|
function renderCommandHelp(command, depth) {
|
|
229
221
|
return [..._duplojs_lang_array.filter([
|
|
230
222
|
renderInline([
|
|
231
|
-
_duplojs_lang_printer.indent(depth),
|
|
232
223
|
section("COMMAND", "green"),
|
|
233
224
|
" ",
|
|
234
225
|
_duplojs_lang_printer.colorizedBold(command.name, "cyan")
|
|
235
|
-
]),
|
|
226
|
+
], depth),
|
|
236
227
|
renderDescriptionLine(command.description, depth + 1),
|
|
237
|
-
_duplojs_lang_printer.renderParagraph([renderInline([
|
|
228
|
+
_duplojs_lang_printer.renderParagraph([renderInline([section("USAGE", "blue")], depth), renderInline([syntax(renderUsage(command))], depth + 1)]),
|
|
238
229
|
command.subject?.type === "argument" ? renderArgumentsHelp(command.subject.args, depth) : null,
|
|
239
230
|
command.subject?.type === "subCommand" ? renderSubCommandsHelp(command.subject.subCommands, depth) : null,
|
|
240
231
|
_duplojs_lang_array.minElements(command.options, 1) ? renderOptionsHelp(command.options, depth) : null
|
|
@@ -244,7 +235,7 @@ function logCommandHelp(command) {
|
|
|
244
235
|
console.log(_duplojs_lang_printer.renderParagraph(renderCommandHelp(command, 0)));
|
|
245
236
|
}
|
|
246
237
|
function renderExecOptionHelp(options, depth) {
|
|
247
|
-
return [renderInline([
|
|
238
|
+
return [renderInline([section("EXEC OPTIONS", "green")], depth), renderOptionsHelp(options, depth)];
|
|
248
239
|
}
|
|
249
240
|
function logExecOptionHelp(options) {
|
|
250
241
|
console.log(_duplojs_lang_printer.renderParagraph(renderExecOptionHelp(options, 0)));
|
package/dist/command/help.mjs
CHANGED
|
@@ -23,8 +23,12 @@ const literal = (input) => DPrinter.colorized(input, "yellow");
|
|
|
23
23
|
const marker = (input) => DPrinter.colorized(input, "yellow");
|
|
24
24
|
const secondary = (input) => DPrinter.colorized(input, "gray");
|
|
25
25
|
const constraintLabel = (input) => DPrinter.colorized(input, "magenta");
|
|
26
|
-
function renderInline(input) {
|
|
27
|
-
return DPrinter.
|
|
26
|
+
function renderInline(input, depth = 0) {
|
|
27
|
+
return DPrinter.renderLine(input, {
|
|
28
|
+
joinCharacter: "",
|
|
29
|
+
indent: DPrinter.Indent.tab,
|
|
30
|
+
indentLevel: depth
|
|
31
|
+
});
|
|
28
32
|
}
|
|
29
33
|
function formatLiteral(value) {
|
|
30
34
|
if (typeof value === "string") return JSON.stringify(value);
|
|
@@ -152,14 +156,10 @@ function renderMetadata(help, markerValue) {
|
|
|
152
156
|
]);
|
|
153
157
|
}
|
|
154
158
|
function renderConstraintLines(constraints, depth) {
|
|
155
|
-
return DArray.map(constraints, (constraint) => renderInline([
|
|
156
|
-
DPrinter.indent(depth),
|
|
157
|
-
secondary("↳ "),
|
|
158
|
-
constraint
|
|
159
|
-
]));
|
|
159
|
+
return DArray.map(constraints, (constraint) => renderInline([secondary("↳ "), constraint], depth));
|
|
160
160
|
}
|
|
161
161
|
function renderDescriptionLine(description, depth) {
|
|
162
|
-
return description ? renderInline([
|
|
162
|
+
return description ? renderInline([secondary(description)], depth) : null;
|
|
163
163
|
}
|
|
164
164
|
function renderUsage(command) {
|
|
165
165
|
const args = command.subject?.type === "argument" ? DArray.map(command.subject.args, (argument) => argument.optional ? `[${argument.name}]` : `<${argument.name}>`) : command.subject?.type === "subCommand" ? ["<command>"] : [];
|
|
@@ -186,48 +186,39 @@ function renderOptionDetails(option, depth) {
|
|
|
186
186
|
if (simpleOptionKind.has(option) || arrayOptionKind.has(option)) {
|
|
187
187
|
const help = renderDataStructure(option.dataStructure);
|
|
188
188
|
return DArray.filter([
|
|
189
|
-
renderInline([
|
|
189
|
+
renderInline([renderMetadata(help, option.required ? "required" : "optional")], depth),
|
|
190
190
|
...renderConstraintLines(help.constraints, depth),
|
|
191
191
|
renderDescriptionLine(option.description, depth)
|
|
192
192
|
], DCommon.truthy);
|
|
193
193
|
}
|
|
194
|
-
if (booleanOptionKind.has(option)) return DArray.filter([renderInline([
|
|
194
|
+
if (booleanOptionKind.has(option)) return DArray.filter([renderInline([typeLabel("boolean")], depth), renderDescriptionLine(option.description, depth)], DCommon.truthy);
|
|
195
195
|
return DArray.filter([renderDescriptionLine(option.description, depth)], DCommon.truthy);
|
|
196
196
|
}
|
|
197
197
|
function renderOptionsHelp(options, depth) {
|
|
198
|
-
return DPrinter.renderParagraph([renderInline([
|
|
198
|
+
return DPrinter.renderParagraph([renderInline([section("OPTIONS", "magenta")], depth), DArray.map(options, (option) => DPrinter.renderParagraph([renderInline([renderOptionSignature(option)], depth + 1), renderOptionDetails(option, depth + 2)]))]);
|
|
199
199
|
}
|
|
200
200
|
function renderArgumentsHelp(args, depth) {
|
|
201
|
-
return DPrinter.renderParagraph([renderInline([
|
|
201
|
+
return DPrinter.renderParagraph([renderInline([section("ARGUMENTS", "cyan")], depth), DArray.map(args, (argument) => {
|
|
202
202
|
const help = renderDataStructure(argument.dataStructure);
|
|
203
203
|
return DPrinter.renderParagraph([
|
|
204
|
-
renderInline([
|
|
205
|
-
DPrinter.indent(depth + 1),
|
|
206
|
-
name(argument.name.padEnd(12)),
|
|
207
|
-
renderMetadata(help, argument.optional ? "optional" : "required")
|
|
208
|
-
]),
|
|
204
|
+
renderInline([name(argument.name.padEnd(12)), renderMetadata(help, argument.optional ? "optional" : "required")], depth + 1),
|
|
209
205
|
renderConstraintLines(help.constraints, depth + 2),
|
|
210
206
|
renderDescriptionLine(argument.description, depth + 2)
|
|
211
207
|
]);
|
|
212
208
|
})]);
|
|
213
209
|
}
|
|
214
210
|
function renderSubCommandsHelp(commands, depth) {
|
|
215
|
-
return DPrinter.renderParagraph([renderInline([
|
|
216
|
-
DPrinter.indent(depth + 1),
|
|
217
|
-
name(command.name.padEnd(16)),
|
|
218
|
-
command.description ? secondary(command.description) : null
|
|
219
|
-
]))]);
|
|
211
|
+
return DPrinter.renderParagraph([renderInline([section("COMMANDS", "green")], depth), DArray.map(commands, (command) => renderInline([name(command.name.padEnd(16)), command.description ? secondary(command.description) : null], depth + 1))]);
|
|
220
212
|
}
|
|
221
213
|
function renderCommandHelp(command, depth) {
|
|
222
214
|
return [...DArray.filter([
|
|
223
215
|
renderInline([
|
|
224
|
-
DPrinter.indent(depth),
|
|
225
216
|
section("COMMAND", "green"),
|
|
226
217
|
" ",
|
|
227
218
|
DPrinter.colorizedBold(command.name, "cyan")
|
|
228
|
-
]),
|
|
219
|
+
], depth),
|
|
229
220
|
renderDescriptionLine(command.description, depth + 1),
|
|
230
|
-
DPrinter.renderParagraph([renderInline([
|
|
221
|
+
DPrinter.renderParagraph([renderInline([section("USAGE", "blue")], depth), renderInline([syntax(renderUsage(command))], depth + 1)]),
|
|
231
222
|
command.subject?.type === "argument" ? renderArgumentsHelp(command.subject.args, depth) : null,
|
|
232
223
|
command.subject?.type === "subCommand" ? renderSubCommandsHelp(command.subject.subCommands, depth) : null,
|
|
233
224
|
DArray.minElements(command.options, 1) ? renderOptionsHelp(command.options, depth) : null
|
|
@@ -237,7 +228,7 @@ function logCommandHelp(command) {
|
|
|
237
228
|
console.log(DPrinter.renderParagraph(renderCommandHelp(command, 0)));
|
|
238
229
|
}
|
|
239
230
|
function renderExecOptionHelp(options, depth) {
|
|
240
|
-
return [renderInline([
|
|
231
|
+
return [renderInline([section("EXEC OPTIONS", "green")], depth), renderOptionsHelp(options, depth)];
|
|
241
232
|
}
|
|
242
233
|
function logExecOptionHelp(options) {
|
|
243
234
|
console.log(DPrinter.renderParagraph(renderExecOptionHelp(options, 0)));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duplojs/server",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "DuploJS",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@duplojs/lang": "0.1.0-beta.
|
|
50
|
+
"@duplojs/lang": "0.1.0-beta.7"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@duplojs/code-config": "0.1.0-beta.
|
|
53
|
+
"@duplojs/code-config": "0.1.0-beta.7",
|
|
54
54
|
"@types/bun": "1.4.1",
|
|
55
55
|
"@types/deno": "2.7.0",
|
|
56
56
|
"@types/node": "24.13.3",
|