@babashka/cli 0.12.75
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/LICENSE +21 -0
- package/README.html +1229 -0
- package/README.md +1837 -0
- package/index.mjs +70 -0
- package/js/babashka/cli/internal.mjs +36 -0
- package/js/babashka/cli.mjs +2797 -0
- package/package.json +28 -0
|
@@ -0,0 +1,2797 @@
|
|
|
1
|
+
import * as squint_core from 'squint-cljs/core.js';
|
|
2
|
+
import * as edn from 'squint-cljs/src/squint/edn.js';
|
|
3
|
+
import * as cljs_DOT_reader from 'squint-cljs/src/squint/edn.js';
|
|
4
|
+
import * as internal from './cli/internal.mjs';
|
|
5
|
+
import * as babashka_DOT_cli_DOT_internal from './cli/internal.mjs';
|
|
6
|
+
import * as str from 'squint-cljs/src/squint/string.js';
|
|
7
|
+
import * as clojure_DOT_string from 'squint-cljs/src/squint/string.js';
|
|
8
|
+
var Injected = function (opt) {
|
|
9
|
+
this.opt = opt;
|
|
10
|
+
|
|
11
|
+
};
|
|
12
|
+
null;
|
|
13
|
+
var __GT_Injected = function (opt) {
|
|
14
|
+
return (new Injected(opt));
|
|
15
|
+
|
|
16
|
+
};
|
|
17
|
+
Injected;
|
|
18
|
+
var merge_opts = (() => {
|
|
19
|
+
const f1 = (function (var_args) {
|
|
20
|
+
const args21 = [];
|
|
21
|
+
const len__23278__auto__2 = arguments.length;
|
|
22
|
+
let i33 = 0;
|
|
23
|
+
while(true){
|
|
24
|
+
if ((i33 < len__23278__auto__2)) {
|
|
25
|
+
args21.push((arguments[i33]));
|
|
26
|
+
let G__4 = (i33 + 1);
|
|
27
|
+
i33 = G__4;
|
|
28
|
+
continue;
|
|
29
|
+
};break;
|
|
30
|
+
}
|
|
31
|
+
;
|
|
32
|
+
const argseq__23536__auto__5 = (((1 < args21.length)) ? (args21.slice(1)) : (null));
|
|
33
|
+
return f1.cljs$core$IFn$_invoke$arity$variadic((arguments[0]), argseq__23536__auto__5);
|
|
34
|
+
|
|
35
|
+
});
|
|
36
|
+
f1.cljs$core$IFn$_invoke$arity$variadic = (function (m, ms) {
|
|
37
|
+
return squint_core.reduce((function (_PERCENT_1, _PERCENT_2) {
|
|
38
|
+
return squint_core.merge_with(internal.merge_STAR_, _PERCENT_1, _PERCENT_2);
|
|
39
|
+
|
|
40
|
+
}), m, ms);
|
|
41
|
+
|
|
42
|
+
});
|
|
43
|
+
f1.cljs$lang$maxFixedArity = 1;
|
|
44
|
+
return f1;
|
|
45
|
+
|
|
46
|
+
})();
|
|
47
|
+
var throw_unexpected = function (s) {
|
|
48
|
+
throw squint_core.ex_info(`${"Unexpected format: "}${s??''}`, ({"s": s}));
|
|
49
|
+
|
|
50
|
+
};
|
|
51
|
+
var parse_boolean = function (x) {
|
|
52
|
+
const v1 = JSON.parse(x);
|
|
53
|
+
if (squint_core.truth_(squint_core.boolean_QMARK_(v1))) {
|
|
54
|
+
return v1} else {
|
|
55
|
+
return throw_unexpected(x)};
|
|
56
|
+
|
|
57
|
+
};
|
|
58
|
+
var parse_long = function (x) {
|
|
59
|
+
const v1 = JSON.parse(x);
|
|
60
|
+
if (squint_core.truth_(squint_core.int_QMARK_(v1))) {
|
|
61
|
+
return v1} else {
|
|
62
|
+
return throw_unexpected(x)};
|
|
63
|
+
|
|
64
|
+
};
|
|
65
|
+
var parse_double = function (x) {
|
|
66
|
+
const v1 = JSON.parse(x);
|
|
67
|
+
if (squint_core.truth_(squint_core.double_QMARK_(v1))) {
|
|
68
|
+
return v1} else {
|
|
69
|
+
return throw_unexpected(x)};
|
|
70
|
+
|
|
71
|
+
};
|
|
72
|
+
var parse_number = function (x) {
|
|
73
|
+
const v1 = JSON.parse(x);
|
|
74
|
+
if (squint_core.truth_(squint_core.number_QMARK_(v1))) {
|
|
75
|
+
return v1} else {
|
|
76
|
+
return throw_unexpected(x)};
|
|
77
|
+
|
|
78
|
+
};
|
|
79
|
+
var number_char_QMARK_ = function (c) {
|
|
80
|
+
return (() => {
|
|
81
|
+
try{
|
|
82
|
+
return parse_number(`${c??''}`);
|
|
83
|
+
}
|
|
84
|
+
catch(_1){
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
})();
|
|
89
|
+
|
|
90
|
+
};
|
|
91
|
+
var first_char = function (arg) {
|
|
92
|
+
if (squint_core.truth_(squint_core.string_QMARK_(arg))) {
|
|
93
|
+
return squint_core.nth(arg, 0, null);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
};
|
|
97
|
+
var second_char = function (arg) {
|
|
98
|
+
if (squint_core.truth_(squint_core.string_QMARK_(arg))) {
|
|
99
|
+
return squint_core.nth(arg, 1, null);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
};
|
|
103
|
+
var parse_keyword = function (s) {
|
|
104
|
+
if ((":" === first_char(s))) {
|
|
105
|
+
return squint_core.keyword(squint_core.subs(s, 1))} else {
|
|
106
|
+
return squint_core.keyword(s)};
|
|
107
|
+
|
|
108
|
+
};
|
|
109
|
+
var coerce_coerce_fn = function (f) {
|
|
110
|
+
if (squint_core.truth_(squint_core.coll_QMARK_(f))) {
|
|
111
|
+
return squint_core.first(f)} else {
|
|
112
|
+
return f};
|
|
113
|
+
|
|
114
|
+
};
|
|
115
|
+
var auto_coerce = function (s) {
|
|
116
|
+
if (squint_core.truth_(squint_core.string_QMARK_(s))) {
|
|
117
|
+
return (() => {
|
|
118
|
+
try{
|
|
119
|
+
const s1 = s;
|
|
120
|
+
const fst_char2 = first_char(s1);
|
|
121
|
+
if (squint_core.truth_((() => {
|
|
122
|
+
const or__23664__auto__3 = ("true" === s1);
|
|
123
|
+
if (or__23664__auto__3) {
|
|
124
|
+
return or__23664__auto__3} else {
|
|
125
|
+
return ("false" === s1)};
|
|
126
|
+
|
|
127
|
+
})())) {
|
|
128
|
+
return parse_boolean(s1)} else {
|
|
129
|
+
if (("nil" === s1)) {
|
|
130
|
+
return null} else {
|
|
131
|
+
if (squint_core.not(isNaN(s1))) {
|
|
132
|
+
return parse_number(s1)} else {
|
|
133
|
+
if (squint_core.truth_(((":" === fst_char2) && squint_core.re_matches(/\:[a-zA-Z][a-zA-Z0-9_/\.-]*/, s1)))) {
|
|
134
|
+
return parse_keyword(s1)} else {
|
|
135
|
+
if ("else") {
|
|
136
|
+
return s1} else {
|
|
137
|
+
return null}}}}};
|
|
138
|
+
}
|
|
139
|
+
catch(_4){
|
|
140
|
+
return s;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
})()} else {
|
|
144
|
+
return s};
|
|
145
|
+
|
|
146
|
+
};
|
|
147
|
+
var coerce_failure_reason = function (s, implicit_value, f) {
|
|
148
|
+
return `${"cannot transform "}${((squint_core.truth_(implicit_value)) ? (`${"(implicit) "}${implicit_value??''}`) : (`${"input "}${squint_core.pr_str(s)??''}`))??''}${((squint_core.truth_(squint_core.keyword_QMARK_(f))) ? (" to ") : (" with "))??''}${((squint_core.truth_(squint_core.keyword_QMARK_(f))) ? (squint_core.name(f)) : (f))??''}`;
|
|
149
|
+
|
|
150
|
+
};
|
|
151
|
+
var throw_coerce = function (s, implicit_value, f, e) {
|
|
152
|
+
throw squint_core.ex_info(`${"Coerce failure: "}${coerce_failure_reason(s, implicit_value, f)??''}`, (() => {
|
|
153
|
+
const G__51 = ({"input": s, "coerce-fn": f});
|
|
154
|
+
if (!(implicit_value == null)) {
|
|
155
|
+
return ({...G__51,["implicit-value"]:implicit_value})} else {
|
|
156
|
+
return G__51};
|
|
157
|
+
|
|
158
|
+
})(), e);
|
|
159
|
+
|
|
160
|
+
};
|
|
161
|
+
var coerce_STAR_ = function (s, f, implicit_value) {
|
|
162
|
+
const f_STAR_1 = (() => {
|
|
163
|
+
const G__62 = f;
|
|
164
|
+
switch (G__62) {case "boolean":
|
|
165
|
+
return parse_boolean;
|
|
166
|
+
|
|
167
|
+
break;
|
|
168
|
+
case "bool":
|
|
169
|
+
return parse_boolean;
|
|
170
|
+
|
|
171
|
+
break;
|
|
172
|
+
case "int":
|
|
173
|
+
return parse_long;
|
|
174
|
+
|
|
175
|
+
break;
|
|
176
|
+
case "long":
|
|
177
|
+
return parse_long;
|
|
178
|
+
|
|
179
|
+
break;
|
|
180
|
+
case "double":
|
|
181
|
+
return parse_double;
|
|
182
|
+
|
|
183
|
+
break;
|
|
184
|
+
case "number":
|
|
185
|
+
return parse_number;
|
|
186
|
+
|
|
187
|
+
break;
|
|
188
|
+
case "symbol":
|
|
189
|
+
return squint_core.symbol;
|
|
190
|
+
|
|
191
|
+
break;
|
|
192
|
+
case "keyword":
|
|
193
|
+
return parse_keyword;
|
|
194
|
+
|
|
195
|
+
break;
|
|
196
|
+
case "string":
|
|
197
|
+
return squint_core.identity;
|
|
198
|
+
|
|
199
|
+
break;
|
|
200
|
+
case "edn":
|
|
201
|
+
return edn.read_string;
|
|
202
|
+
|
|
203
|
+
break;
|
|
204
|
+
case "auto":
|
|
205
|
+
return auto_coerce;
|
|
206
|
+
|
|
207
|
+
break;
|
|
208
|
+
default:
|
|
209
|
+
return f};
|
|
210
|
+
|
|
211
|
+
})();
|
|
212
|
+
const res4 = ((squint_core.truth_(squint_core.string_QMARK_(s))) ? ((() => {
|
|
213
|
+
try{
|
|
214
|
+
return f_STAR_1(s);
|
|
215
|
+
}
|
|
216
|
+
catch(e5){
|
|
217
|
+
return throw_coerce(s, implicit_value, f, e5);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
})()) : (s));
|
|
221
|
+
if (squint_core.truth_((!(implicit_value == null) && !squint_core._EQ_(implicit_value, res4)))) {
|
|
222
|
+
return throw_coerce(s, implicit_value, f, null)} else {
|
|
223
|
+
return res4};
|
|
224
|
+
|
|
225
|
+
};
|
|
226
|
+
var coerce = function (s, f) {
|
|
227
|
+
return coerce_STAR_(s, f, null);
|
|
228
|
+
|
|
229
|
+
};
|
|
230
|
+
var collect_fn = function (collect_opts, coerce_map, opt) {
|
|
231
|
+
const f1 = (() => {
|
|
232
|
+
const or__23664__auto__2 = squint_core.get(collect_opts, opt);
|
|
233
|
+
if (squint_core.truth_(or__23664__auto__2)) {
|
|
234
|
+
return or__23664__auto__2} else {
|
|
235
|
+
const k3 = squint_core.get(coerce_map, opt);
|
|
236
|
+
if (squint_core.truth_(squint_core.coll_QMARK_(k3))) {
|
|
237
|
+
return squint_core.empty(k3);
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
})();
|
|
242
|
+
if (squint_core.truth_(f1)) {
|
|
243
|
+
if (squint_core.truth_(squint_core.coll_QMARK_(f1))) {
|
|
244
|
+
return squint_core.fnil(squint_core.conj, f1)} else {
|
|
245
|
+
return f1};
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
};
|
|
249
|
+
var maybe_close_open_opt = function (acc, open_opt, valued_opt, opt_val_collector) {
|
|
250
|
+
if (!squint_core._EQ_(open_opt, valued_opt)) {
|
|
251
|
+
const v1 = ((squint_core.truth_(opt_val_collector)) ? (opt_val_collector(squint_core.get(acc, open_opt), true)) : (true));
|
|
252
|
+
return squint_core.assoc(acc, open_opt, v1);
|
|
253
|
+
} else {
|
|
254
|
+
return acc};
|
|
255
|
+
|
|
256
|
+
};
|
|
257
|
+
var add_val_to_opt = function (acc, opt, opt_val_collector, val) {
|
|
258
|
+
if (squint_core.truth_(opt_val_collector)) {
|
|
259
|
+
return squint_core.update(acc, opt, opt_val_collector, val)} else {
|
|
260
|
+
return squint_core.assoc(acc, opt, val)};
|
|
261
|
+
|
|
262
|
+
};
|
|
263
|
+
var spec__GT_opts = (() => {
|
|
264
|
+
const f7 = (function (...args8) {
|
|
265
|
+
const G__91 = args8.length;
|
|
266
|
+
switch (G__91) {case 1:
|
|
267
|
+
return f7.cljs$core$IFn$_invoke$arity$1(args8[0]);
|
|
268
|
+
|
|
269
|
+
break;
|
|
270
|
+
case 2:
|
|
271
|
+
return f7.cljs$core$IFn$_invoke$arity$2(args8[0], args8[1]);
|
|
272
|
+
|
|
273
|
+
break;
|
|
274
|
+
default:
|
|
275
|
+
throw (new Error(`${"Invalid arity: "}${args8.length??''}`))};
|
|
276
|
+
|
|
277
|
+
});
|
|
278
|
+
f7.cljs$core$IFn$_invoke$arity$1 = (function (spec) {
|
|
279
|
+
return spec__GT_opts(spec, null);
|
|
280
|
+
|
|
281
|
+
});
|
|
282
|
+
f7.cljs$core$IFn$_invoke$arity$2 = (function (spec, p__10) {
|
|
283
|
+
const map__34 = p__10;
|
|
284
|
+
const exec_args5 = squint_core.get(map__34, "exec-args");
|
|
285
|
+
return squint_core.reduce((function (acc, p__11) {
|
|
286
|
+
const vec__610 = p__11;
|
|
287
|
+
const k11 = squint_core.nth(vec__610, 0, null);
|
|
288
|
+
const map__912 = squint_core.nth(vec__610, 1, null);
|
|
289
|
+
const coerce13 = squint_core.get(map__912, "coerce");
|
|
290
|
+
const collect14 = squint_core.get(map__912, "collect");
|
|
291
|
+
const alias15 = squint_core.get(map__912, "alias");
|
|
292
|
+
const default$16 = squint_core.get(map__912, "default");
|
|
293
|
+
const require17 = squint_core.get(map__912, "require");
|
|
294
|
+
const validate18 = squint_core.get(map__912, "validate");
|
|
295
|
+
const G__1219 = acc;
|
|
296
|
+
const G__1220 = ((squint_core.truth_(coerce13)) ? (squint_core.update(G__1219, "coerce", squint_core.assoc, k11, coerce13)) : (G__1219));
|
|
297
|
+
const G__1221 = ((squint_core.truth_(collect14)) ? (squint_core.update(G__1220, "collect", squint_core.assoc, k11, collect14)) : (G__1220));
|
|
298
|
+
const G__1222 = ((squint_core.truth_(alias15)) ? (squint_core.update(G__1221, "alias", (function (aliases) {
|
|
299
|
+
if (squint_core.truth_(squint_core.contains_QMARK_(aliases, alias15))) {
|
|
300
|
+
throw squint_core.ex_info(`${"Conflicting alias "}${alias15??''}${" between "}${squint_core.get(aliases, alias15)??''}${" and "}${k11??''}`, ({"alias": alias15}))};
|
|
301
|
+
return squint_core.assoc(aliases, alias15, k11);
|
|
302
|
+
|
|
303
|
+
}))) : (G__1221));
|
|
304
|
+
const G__1223 = ((squint_core.truth_(require17)) ? (squint_core.update(G__1222, "require", squint_core.fnil((function (_PERCENT_1) {
|
|
305
|
+
return squint_core.conj(_PERCENT_1, k11);
|
|
306
|
+
|
|
307
|
+
}), (new Set ([]))))) : (G__1222));
|
|
308
|
+
const G__1224 = ((squint_core.truth_(validate18)) ? (squint_core.update(G__1223, "validate", squint_core.assoc, k11, validate18)) : (G__1223));
|
|
309
|
+
if (!(default$16 == null)) {
|
|
310
|
+
return squint_core.update(G__1224, "exec-args", (function (new_exec_args) {
|
|
311
|
+
return squint_core.assoc(new_exec_args, k11, squint_core.get(exec_args5, k11, default$16));
|
|
312
|
+
|
|
313
|
+
}))} else {
|
|
314
|
+
return G__1224};
|
|
315
|
+
|
|
316
|
+
}), ({}), spec);
|
|
317
|
+
|
|
318
|
+
});
|
|
319
|
+
f7.cljs$lang$maxFixedArity = 2;
|
|
320
|
+
return f7;
|
|
321
|
+
|
|
322
|
+
})();
|
|
323
|
+
var parse_cmds = (() => {
|
|
324
|
+
const f13 = (function (...args14) {
|
|
325
|
+
const G__151 = args14.length;
|
|
326
|
+
switch (G__151) {case 1:
|
|
327
|
+
return f13.cljs$core$IFn$_invoke$arity$1(args14[0]);
|
|
328
|
+
|
|
329
|
+
break;
|
|
330
|
+
case 2:
|
|
331
|
+
return f13.cljs$core$IFn$_invoke$arity$2(args14[0], args14[1]);
|
|
332
|
+
|
|
333
|
+
break;
|
|
334
|
+
default:
|
|
335
|
+
throw (new Error(`${"Invalid arity: "}${args14.length??''}`))};
|
|
336
|
+
|
|
337
|
+
});
|
|
338
|
+
f13.cljs$core$IFn$_invoke$arity$1 = (function (args) {
|
|
339
|
+
return parse_cmds(args, null);
|
|
340
|
+
|
|
341
|
+
});
|
|
342
|
+
f13.cljs$core$IFn$_invoke$arity$2 = (function (args, p__16) {
|
|
343
|
+
const map__34 = p__16;
|
|
344
|
+
const no_keyword_opts5 = squint_core.get(map__34, "no-keyword-opts");
|
|
345
|
+
const vec__69 = squint_core.split_with((function (_PERCENT_1) {
|
|
346
|
+
return squint_core.not((() => {
|
|
347
|
+
const or__23664__auto__10 = ((squint_core.truth_(no_keyword_opts5)) ? (null) : (str.starts_with_QMARK_(_PERCENT_1, ":")));
|
|
348
|
+
if (squint_core.truth_(or__23664__auto__10)) {
|
|
349
|
+
return or__23664__auto__10} else {
|
|
350
|
+
return str.starts_with_QMARK_(_PERCENT_1, "-")};
|
|
351
|
+
|
|
352
|
+
})());
|
|
353
|
+
|
|
354
|
+
}), args);
|
|
355
|
+
const cmds11 = squint_core.nth(vec__69, 0, null);
|
|
356
|
+
const args12 = squint_core.nth(vec__69, 1, null);
|
|
357
|
+
return ({"cmds": cmds11, "args": args12});
|
|
358
|
+
|
|
359
|
+
});
|
|
360
|
+
f13.cljs$lang$maxFixedArity = 2;
|
|
361
|
+
return f13;
|
|
362
|
+
|
|
363
|
+
})();
|
|
364
|
+
var args__GT_opts = (() => {
|
|
365
|
+
const f17 = (function (...args18) {
|
|
366
|
+
const G__191 = args18.length;
|
|
367
|
+
switch (G__191) {case 2:
|
|
368
|
+
return f17.cljs$core$IFn$_invoke$arity$2(args18[0], args18[1]);
|
|
369
|
+
|
|
370
|
+
break;
|
|
371
|
+
case 3:
|
|
372
|
+
return f17.cljs$core$IFn$_invoke$arity$3(args18[0], args18[1], args18[2]);
|
|
373
|
+
|
|
374
|
+
break;
|
|
375
|
+
default:
|
|
376
|
+
throw (new Error(`${"Invalid arity: "}${args18.length??''}`))};
|
|
377
|
+
|
|
378
|
+
});
|
|
379
|
+
f17.cljs$core$IFn$_invoke$arity$2 = (function (args, args__GT_opt_keys) {
|
|
380
|
+
return args__GT_opts(args, args__GT_opt_keys, (new Set ([])));
|
|
381
|
+
|
|
382
|
+
});
|
|
383
|
+
f17.cljs$core$IFn$_invoke$arity$3 = (function (args, args__GT_opt_keys, ignored_args) {
|
|
384
|
+
const vec__36 = ((squint_core.truth_(args__GT_opt_keys)) ? (((squint_core.truth_((() => {
|
|
385
|
+
const and__23691__auto__7 = squint_core.seq(args);
|
|
386
|
+
if (squint_core.truth_(and__23691__auto__7)) {
|
|
387
|
+
return squint_core.not(squint_core.contains_QMARK_(ignored_args, squint_core.first(args)))} else {
|
|
388
|
+
return and__23691__auto__7};
|
|
389
|
+
|
|
390
|
+
})())) ? ((() => {
|
|
391
|
+
const arg_count8 = squint_core.count(args);
|
|
392
|
+
const cnt9 = squint_core.min(arg_count8, squint_core.bounded_count(arg_count8, args__GT_opt_keys));
|
|
393
|
+
return [squint_core.concat(squint_core.interleave(squint_core.map(__GT_Injected, args__GT_opt_keys), args), squint_core.drop(cnt9, args)), squint_core.drop(cnt9, args__GT_opt_keys)];
|
|
394
|
+
|
|
395
|
+
})()) : ([args, args__GT_opt_keys]))) : ([args, args__GT_opt_keys]));
|
|
396
|
+
const new_args10 = squint_core.nth(vec__36, 0, null);
|
|
397
|
+
const args__GT_opts11 = squint_core.nth(vec__36, 1, null);
|
|
398
|
+
return ({"args": new_args10, "args->opts": args__GT_opts11});
|
|
399
|
+
|
|
400
|
+
});
|
|
401
|
+
f17.cljs$lang$maxFixedArity = 3;
|
|
402
|
+
return f17;
|
|
403
|
+
|
|
404
|
+
})();
|
|
405
|
+
var analyze_arg = function (arg, mode, open_opt, boolean_opt_QMARK_, valued_opt, known_keys, alias_keys) {
|
|
406
|
+
const fst_char1 = first_char(arg);
|
|
407
|
+
const snd_char2 = second_char(arg);
|
|
408
|
+
const hyphen_opt_QMARK_3 = (!("keywords" === mode) && (("-" === fst_char1) && ((squint_core.count(arg) > 1) && (() => {
|
|
409
|
+
const k4 = squint_core.keyword(squint_core.subs(arg, 1));
|
|
410
|
+
const or__23664__auto__5 = squint_core.contains_QMARK_(known_keys, k4);
|
|
411
|
+
if (squint_core.truth_(or__23664__auto__5)) {
|
|
412
|
+
return or__23664__auto__5} else {
|
|
413
|
+
const or__23664__auto__6 = squint_core.contains_QMARK_(alias_keys, k4);
|
|
414
|
+
if (squint_core.truth_(or__23664__auto__6)) {
|
|
415
|
+
return or__23664__auto__6} else {
|
|
416
|
+
return squint_core.not(number_char_QMARK_(snd_char2))};
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
})())));
|
|
420
|
+
const mode7 = (() => {
|
|
421
|
+
const or__23664__auto__8 = mode;
|
|
422
|
+
if (squint_core.truth_(or__23664__auto__8)) {
|
|
423
|
+
return or__23664__auto__8} else {
|
|
424
|
+
if (squint_core.truth_(hyphen_opt_QMARK_3)) {
|
|
425
|
+
return "hyphens";
|
|
426
|
+
}};
|
|
427
|
+
|
|
428
|
+
})();
|
|
429
|
+
const fst_colon_QMARK_9 = (":" === fst_char1);
|
|
430
|
+
const kwd_opt_QMARK_10 = (!("hyphens" === mode7) && (fst_colon_QMARK_9 && (() => {
|
|
431
|
+
const or__23664__auto__11 = boolean_opt_QMARK_;
|
|
432
|
+
if (squint_core.truth_(or__23664__auto__11)) {
|
|
433
|
+
return or__23664__auto__11} else {
|
|
434
|
+
const or__23664__auto__12 = squint_core.not(open_opt);
|
|
435
|
+
if (or__23664__auto__12) {
|
|
436
|
+
return or__23664__auto__12} else {
|
|
437
|
+
return squint_core._EQ_(valued_opt, open_opt)};
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
})()));
|
|
441
|
+
const mode13 = (() => {
|
|
442
|
+
const or__23664__auto__14 = mode7;
|
|
443
|
+
if (squint_core.truth_(or__23664__auto__14)) {
|
|
444
|
+
return or__23664__auto__14} else {
|
|
445
|
+
if (squint_core.truth_(kwd_opt_QMARK_10)) {
|
|
446
|
+
return "keywords";
|
|
447
|
+
}};
|
|
448
|
+
|
|
449
|
+
})();
|
|
450
|
+
const composite_opt_QMARK_15 = ((squint_core.truth_(hyphen_opt_QMARK_3)) ? ((() => {
|
|
451
|
+
const and__23691__auto__16 = snd_char2;
|
|
452
|
+
if (squint_core.truth_(and__23691__auto__16)) {
|
|
453
|
+
return (!("-" === snd_char2) && (squint_core.count(arg) > 2))} else {
|
|
454
|
+
return and__23691__auto__16};
|
|
455
|
+
|
|
456
|
+
})()) : (null));
|
|
457
|
+
return ({"mode": mode13, "hyphen-opt": hyphen_opt_QMARK_3, "composite-opt": composite_opt_QMARK_15, "kwd-opt": kwd_opt_QMARK_10, "fst-colon": fst_colon_QMARK_9});
|
|
458
|
+
|
|
459
|
+
};
|
|
460
|
+
var __GT_error_fn = function (spec, error_fn_opt) {
|
|
461
|
+
const f1 = (() => {
|
|
462
|
+
const or__23664__auto__2 = error_fn_opt;
|
|
463
|
+
if (squint_core.truth_(or__23664__auto__2)) {
|
|
464
|
+
return or__23664__auto__2} else {
|
|
465
|
+
return function (data) {
|
|
466
|
+
throw squint_core.ex_info(squint_core.get(data, "msg"), data);
|
|
467
|
+
|
|
468
|
+
}};
|
|
469
|
+
|
|
470
|
+
})();
|
|
471
|
+
return function (data) {
|
|
472
|
+
return f1(squint_core.merge(({"spec": spec, "type": "org.babashka/cli"}), data));
|
|
473
|
+
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
};
|
|
477
|
+
var resolve_opts = function (opts) {
|
|
478
|
+
if (squint_core.truth_(squint_core.get(opts, "babashka.cli/resolved"))) {
|
|
479
|
+
return opts} else {
|
|
480
|
+
const spec1 = squint_core.get(opts, "spec");
|
|
481
|
+
return squint_core.assoc(((squint_core.truth_(spec1)) ? (merge_opts(opts, spec__GT_opts(spec1, opts))) : (opts)), "babashka.cli/resolved", true);
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
};
|
|
485
|
+
var kw__GT_str = function (kw) {
|
|
486
|
+
return `${kw??''}`;
|
|
487
|
+
|
|
488
|
+
};
|
|
489
|
+
var option_label = function (opt__GT_flag, opt) {
|
|
490
|
+
const or__23664__auto__1 = squint_core.get(opt__GT_flag, opt);
|
|
491
|
+
if (squint_core.truth_(or__23664__auto__1)) {
|
|
492
|
+
return or__23664__auto__1} else {
|
|
493
|
+
return `--${kw__GT_str(opt)??''}`};
|
|
494
|
+
|
|
495
|
+
};
|
|
496
|
+
var coerce_opts = (() => {
|
|
497
|
+
const f20 = (function (...args21) {
|
|
498
|
+
const G__221 = args21.length;
|
|
499
|
+
switch (G__221) {case 1:
|
|
500
|
+
return f20.cljs$core$IFn$_invoke$arity$1(args21[0]);
|
|
501
|
+
|
|
502
|
+
break;
|
|
503
|
+
case 2:
|
|
504
|
+
return f20.cljs$core$IFn$_invoke$arity$2(args21[0], args21[1]);
|
|
505
|
+
|
|
506
|
+
break;
|
|
507
|
+
default:
|
|
508
|
+
throw (new Error(`${"Invalid arity: "}${args21.length??''}`))};
|
|
509
|
+
|
|
510
|
+
});
|
|
511
|
+
f20.cljs$core$IFn$_invoke$arity$1 = (function (m) {
|
|
512
|
+
return coerce_opts(m, ({}));
|
|
513
|
+
|
|
514
|
+
});
|
|
515
|
+
f20.cljs$core$IFn$_invoke$arity$2 = (function (m, opts) {
|
|
516
|
+
const spec3 = squint_core.get(opts, "spec");
|
|
517
|
+
const opts4 = resolve_opts(opts);
|
|
518
|
+
const coerce_map5 = squint_core.get(opts4, "coerce");
|
|
519
|
+
const m_meta6 = squint_core.meta(m);
|
|
520
|
+
const implicit_values7 = (() => {
|
|
521
|
+
const or__23664__auto__8 = squint_core.get(opts4, "babashka.cli/implicit-values");
|
|
522
|
+
if (squint_core.truth_(or__23664__auto__8)) {
|
|
523
|
+
return or__23664__auto__8} else {
|
|
524
|
+
return squint_core.get(m_meta6, "babashka.cli/implicit-values")};
|
|
525
|
+
|
|
526
|
+
})();
|
|
527
|
+
const auto_coerce_QMARK_9 = squint_core.get(opts4, "babashka.cli/auto-coerce");
|
|
528
|
+
const keys_order10 = (() => {
|
|
529
|
+
const or__23664__auto__11 = squint_core.get(opts4, "babashka.cli/keys-order");
|
|
530
|
+
if (squint_core.truth_(or__23664__auto__11)) {
|
|
531
|
+
return or__23664__auto__11} else {
|
|
532
|
+
return squint_core.get(m_meta6, "babashka.cli/keys-order")};
|
|
533
|
+
|
|
534
|
+
})();
|
|
535
|
+
const error_fn12 = __GT_error_fn(spec3, squint_core.get(opts4, "error-fn"));
|
|
536
|
+
if (squint_core.truth_((() => {
|
|
537
|
+
const or__23664__auto__13 = squint_core.seq(coerce_map5);
|
|
538
|
+
if (squint_core.truth_(or__23664__auto__13)) {
|
|
539
|
+
return or__23664__auto__13} else {
|
|
540
|
+
return auto_coerce_QMARK_9};
|
|
541
|
+
|
|
542
|
+
})())) {
|
|
543
|
+
const coerce_114 = (function (v, cf, implicit_value) {
|
|
544
|
+
if (squint_core.truth_(cf)) {
|
|
545
|
+
return coerce_STAR_(v, cf, implicit_value)} else {
|
|
546
|
+
return auto_coerce(v)};
|
|
547
|
+
|
|
548
|
+
});
|
|
549
|
+
const ordered_keys15 = ((squint_core.truth_(squint_core.seq(keys_order10))) ? (squint_core.concat(keys_order10, squint_core.remove(squint_core.set(keys_order10), squint_core.keys(m)))) : (squint_core.keys(m)));
|
|
550
|
+
return squint_core.with_meta(squint_core.reduce((function (acc, k) {
|
|
551
|
+
const v16 = squint_core.get(m, k);
|
|
552
|
+
const temp__23189__auto__17 = squint_core.get(coerce_map5, k);
|
|
553
|
+
if (squint_core.truth_(temp__23189__auto__17)) {
|
|
554
|
+
const coerce_k18 = temp__23189__auto__17;
|
|
555
|
+
const coll_coerce_QMARK_19 = squint_core.coll_QMARK_(coerce_k18);
|
|
556
|
+
const empty_coll20 = ((squint_core.truth_(coll_coerce_QMARK_19)) ? ((() => {
|
|
557
|
+
const or__23664__auto__21 = squint_core.empty(coerce_k18);
|
|
558
|
+
if (squint_core.truth_(or__23664__auto__21)) {
|
|
559
|
+
return or__23664__auto__21} else {
|
|
560
|
+
return []};
|
|
561
|
+
|
|
562
|
+
})()) : (null));
|
|
563
|
+
const cf22 = coerce_coerce_fn(coerce_k18);
|
|
564
|
+
const iv23 = (() => {
|
|
565
|
+
const and__23691__auto__24 = implicit_values7;
|
|
566
|
+
if (squint_core.truth_(and__23691__auto__24)) {
|
|
567
|
+
return squint_core.get(implicit_values7, k)} else {
|
|
568
|
+
return and__23691__auto__24};
|
|
569
|
+
|
|
570
|
+
})();
|
|
571
|
+
return (() => {
|
|
572
|
+
try{
|
|
573
|
+
if (squint_core.truth_((() => {
|
|
574
|
+
const and__23691__auto__25 = coll_coerce_QMARK_19;
|
|
575
|
+
if (squint_core.truth_(and__23691__auto__25)) {
|
|
576
|
+
return squint_core.coll_QMARK_(v16)} else {
|
|
577
|
+
return and__23691__auto__25};
|
|
578
|
+
|
|
579
|
+
})())) {
|
|
580
|
+
return squint_core.assoc(acc, k, squint_core.reduce((function (coll, elem) {
|
|
581
|
+
return squint_core.conj(coll, coerce_114(elem, cf22, iv23));
|
|
582
|
+
|
|
583
|
+
}), empty_coll20, v16))} else {
|
|
584
|
+
if (squint_core.truth_(coll_coerce_QMARK_19)) {
|
|
585
|
+
return squint_core.assoc(acc, k, squint_core.conj(empty_coll20, coerce_114(v16, cf22, iv23)))} else {
|
|
586
|
+
if (squint_core.truth_(squint_core.coll_QMARK_(v16))) {
|
|
587
|
+
return squint_core.assoc(acc, k, squint_core.into(squint_core.empty(v16), squint_core.map((function (_PERCENT_1) {
|
|
588
|
+
return coerce_114(_PERCENT_1, cf22, iv23);
|
|
589
|
+
|
|
590
|
+
})), v16))} else {
|
|
591
|
+
if ("else") {
|
|
592
|
+
return squint_core.assoc(acc, k, coerce_114(v16, cf22, iv23))} else {
|
|
593
|
+
return null}}}};
|
|
594
|
+
}
|
|
595
|
+
catch(e26){
|
|
596
|
+
const data27 = squint_core.ex_data(e26);
|
|
597
|
+
const km28 = squint_core.get(m_meta6, "babashka.cli/opt->flag");
|
|
598
|
+
const flag29 = squint_core.get(km28, k);
|
|
599
|
+
const iv30 = squint_core.get(data27, "implicit-value");
|
|
600
|
+
error_fn12((() => {
|
|
601
|
+
const G__2331 = ({"cause": "coerce", "msg": (() => {
|
|
602
|
+
const G__2432 = iv30;
|
|
603
|
+
if ((true === G__2432)) {
|
|
604
|
+
return `${"Missing value for option "}${option_label(km28, k)??''}`} else {
|
|
605
|
+
if ((false === G__2432)) {
|
|
606
|
+
return `${"Cannot negate option "}${option_label(km28, k).replace("no-", "")??''}`} else {
|
|
607
|
+
if ("else") {
|
|
608
|
+
return `${"Invalid value for option "}${option_label(km28, k)??''}${": "}${coerce_failure_reason(squint_core.get(data27, "input"), iv30, squint_core.get(data27, "coerce-fn"))??''}`} else {
|
|
609
|
+
return null}}};
|
|
610
|
+
|
|
611
|
+
})(), "option": k, "value": v16, "opts": acc});
|
|
612
|
+
const G__2333 = ((squint_core.truth_(flag29)) ? (({...G__2331,["flag"]:flag29})) : (G__2331));
|
|
613
|
+
if (squint_core.truth_(iv30)) {
|
|
614
|
+
return squint_core.assoc(G__2333, "implicit-value", squint_core.get(data27, "implicit-value"))} else {
|
|
615
|
+
return G__2333};
|
|
616
|
+
|
|
617
|
+
})());
|
|
618
|
+
return acc;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
})();
|
|
622
|
+
} else {
|
|
623
|
+
if (squint_core.truth_(auto_coerce_QMARK_9)) {
|
|
624
|
+
return squint_core.assoc(acc, k, auto_coerce(v16))} else {
|
|
625
|
+
return squint_core.assoc(acc, k, v16)}};
|
|
626
|
+
|
|
627
|
+
}), ({}), ordered_keys15), squint_core.meta(m));
|
|
628
|
+
} else {
|
|
629
|
+
return m};
|
|
630
|
+
|
|
631
|
+
});
|
|
632
|
+
f20.cljs$lang$maxFixedArity = 2;
|
|
633
|
+
return f20;
|
|
634
|
+
|
|
635
|
+
})();
|
|
636
|
+
var validate_opts = (() => {
|
|
637
|
+
const f25 = (function (...args26) {
|
|
638
|
+
const G__271 = args26.length;
|
|
639
|
+
switch (G__271) {case 1:
|
|
640
|
+
return f25.cljs$core$IFn$_invoke$arity$1(args26[0]);
|
|
641
|
+
|
|
642
|
+
break;
|
|
643
|
+
case 2:
|
|
644
|
+
return f25.cljs$core$IFn$_invoke$arity$2(args26[0], args26[1]);
|
|
645
|
+
|
|
646
|
+
break;
|
|
647
|
+
default:
|
|
648
|
+
throw (new Error(`${"Invalid arity: "}${args26.length??''}`))};
|
|
649
|
+
|
|
650
|
+
});
|
|
651
|
+
f25.cljs$core$IFn$_invoke$arity$1 = (function (m) {
|
|
652
|
+
return validate_opts(m, ({}));
|
|
653
|
+
|
|
654
|
+
});
|
|
655
|
+
f25.cljs$core$IFn$_invoke$arity$2 = (function (m, opts) {
|
|
656
|
+
const spec3 = squint_core.get(opts, "spec");
|
|
657
|
+
const opts4 = resolve_opts(opts);
|
|
658
|
+
const coerce_map5 = squint_core.get(opts4, "coerce");
|
|
659
|
+
const aliases6 = (() => {
|
|
660
|
+
const or__23664__auto__7 = squint_core.get(opts4, "alias");
|
|
661
|
+
if (squint_core.truth_(or__23664__auto__7)) {
|
|
662
|
+
return or__23664__auto__7} else {
|
|
663
|
+
return squint_core.get(opts4, "aliases")};
|
|
664
|
+
|
|
665
|
+
})();
|
|
666
|
+
const spec_map8 = ((squint_core.truth_(squint_core.map_QMARK_(spec3))) ? (spec3) : (((squint_core.truth_(spec3)) ? (squint_core.into(({}), spec3)) : (null))));
|
|
667
|
+
const known_keys9 = squint_core.set(squint_core.concat(squint_core.keys(spec_map8), squint_core.vals(aliases6), squint_core.keys(coerce_map5)));
|
|
668
|
+
const restrict10 = (() => {
|
|
669
|
+
const or__23664__auto__11 = squint_core.get(opts4, "restrict");
|
|
670
|
+
if (squint_core.truth_(or__23664__auto__11)) {
|
|
671
|
+
return or__23664__auto__11} else {
|
|
672
|
+
return squint_core.get(opts4, "closed")};
|
|
673
|
+
|
|
674
|
+
})();
|
|
675
|
+
const restrict12 = ((squint_core.truth_(squint_core.true_QMARK_(restrict10))) ? (known_keys9) : ((() => {
|
|
676
|
+
const G__2813 = restrict10;
|
|
677
|
+
if ((G__2813 == null)) {
|
|
678
|
+
return null} else {
|
|
679
|
+
return squint_core.set(G__2813)};
|
|
680
|
+
|
|
681
|
+
})()));
|
|
682
|
+
const require14 = squint_core.get(opts4, "require");
|
|
683
|
+
const validate15 = squint_core.get(opts4, "validate");
|
|
684
|
+
const inherited16 = squint_core.get(opts4, "babashka.cli/dispatch-inherited");
|
|
685
|
+
const exec_args17 = squint_core.get(opts4, "exec-args");
|
|
686
|
+
const opt__GT_flag18 = squint_core.get(squint_core.meta(m), "babashka.cli/opt->flag");
|
|
687
|
+
const flag_for19 = (function (k) {
|
|
688
|
+
return option_label(opt__GT_flag18, k);
|
|
689
|
+
|
|
690
|
+
});
|
|
691
|
+
const error_fn20 = __GT_error_fn(spec3, squint_core.get(opts4, "error-fn"));
|
|
692
|
+
if (squint_core.truth_(restrict12)) {
|
|
693
|
+
for (let G__21 of squint_core.iterable(squint_core.keys(m))) {
|
|
694
|
+
const k22 = G__21;
|
|
695
|
+
if (squint_core.truth_((squint_core.not(squint_core.contains_QMARK_(restrict12, k22)) && (squint_core.not(squint_core.contains_QMARK_(inherited16, k22)) && (squint_core.not(squint_core.contains_QMARK_(exec_args17, k22)) && !("babashka.cli" === squint_core.namespace(k22))))))) {
|
|
696
|
+
const flag23 = squint_core.get(opt__GT_flag18, k22);
|
|
697
|
+
error_fn20((() => {
|
|
698
|
+
const G__2924 = ({"cause": "restrict", "msg": `${"Unknown option: "}${flag_for19(k22)??''}`, "restrict": restrict12, "option": k22, "opts": m});
|
|
699
|
+
if (squint_core.truth_(flag23)) {
|
|
700
|
+
return ({...G__2924,["flag"]:flag23})} else {
|
|
701
|
+
return G__2924};
|
|
702
|
+
|
|
703
|
+
})())}
|
|
704
|
+
}};
|
|
705
|
+
if (squint_core.truth_(require14)) {
|
|
706
|
+
for (let G__25 of squint_core.iterable(require14)) {
|
|
707
|
+
const k26 = G__25;
|
|
708
|
+
if (squint_core.truth_(squint_core.find(m, k26))) {
|
|
709
|
+
} else {
|
|
710
|
+
const flag27 = squint_core.get(opt__GT_flag18, k26);
|
|
711
|
+
error_fn20((() => {
|
|
712
|
+
const G__3028 = ({"cause": "require", "msg": `${"Required option: "}${flag_for19(k26)??''}`, "require": require14, "option": k26, "opts": m});
|
|
713
|
+
if (squint_core.truth_(flag27)) {
|
|
714
|
+
return ({...G__3028,["flag"]:flag27})} else {
|
|
715
|
+
return G__3028};
|
|
716
|
+
|
|
717
|
+
})())}
|
|
718
|
+
}};
|
|
719
|
+
if (squint_core.truth_(validate15)) {
|
|
720
|
+
for (let G__29 of squint_core.iterable(validate15)) {
|
|
721
|
+
const vec__3033 = G__29;
|
|
722
|
+
const k34 = squint_core.nth(vec__3033, 0, null);
|
|
723
|
+
const vf35 = squint_core.nth(vec__3033, 1, null);
|
|
724
|
+
const f36 = (() => {
|
|
725
|
+
const or__23664__auto__37 = (() => {
|
|
726
|
+
const and__23691__auto__38 = squint_core.map_QMARK_(vf35);
|
|
727
|
+
if (squint_core.truth_(and__23691__auto__38)) {
|
|
728
|
+
return squint_core.get(vf35, "pred")} else {
|
|
729
|
+
return and__23691__auto__38};
|
|
730
|
+
|
|
731
|
+
})();
|
|
732
|
+
if (squint_core.truth_(or__23664__auto__37)) {
|
|
733
|
+
return or__23664__auto__37} else {
|
|
734
|
+
return vf35};
|
|
735
|
+
|
|
736
|
+
})();
|
|
737
|
+
const temp__23259__auto__39 = squint_core.find(m, k34);
|
|
738
|
+
if (squint_core.truth_(temp__23259__auto__39)) {
|
|
739
|
+
const vec__4043 = temp__23259__auto__39;
|
|
740
|
+
const _44 = squint_core.nth(vec__4043, 0, null);
|
|
741
|
+
const v45 = squint_core.nth(vec__4043, 1, null);
|
|
742
|
+
if (squint_core.truth_(((squint_core.truth_(squint_core.set_QMARK_(f36))) ? (squint_core.contains_QMARK_(f36, v45)) : (f36(v45))))) {
|
|
743
|
+
} else {
|
|
744
|
+
const ex_msg_fn46 = (() => {
|
|
745
|
+
const or__23664__auto__47 = squint_core.get(vf35, "ex-msg");
|
|
746
|
+
if (squint_core.truth_(or__23664__auto__47)) {
|
|
747
|
+
return or__23664__auto__47} else {
|
|
748
|
+
return function (p__31) {
|
|
749
|
+
const map__4849 = p__31;
|
|
750
|
+
const flag50 = squint_core.get(map__4849, "flag");
|
|
751
|
+
const value51 = squint_core.get(map__4849, "value");
|
|
752
|
+
return `${"Invalid value for option "}${flag50??''}${": "}${value51??''}`;
|
|
753
|
+
|
|
754
|
+
}};
|
|
755
|
+
|
|
756
|
+
})();
|
|
757
|
+
const flag52 = squint_core.get(opt__GT_flag18, k34);
|
|
758
|
+
error_fn20((() => {
|
|
759
|
+
const G__3253 = ({"cause": "validate", "msg": ex_msg_fn46(({"option": k34, "value": v45, "flag": flag_for19(k34)})), "validate": validate15, "option": k34, "value": v45, "opts": m});
|
|
760
|
+
if (squint_core.truth_(flag52)) {
|
|
761
|
+
return ({...G__3253,["flag"]:flag52})} else {
|
|
762
|
+
return G__3253};
|
|
763
|
+
|
|
764
|
+
})())}}
|
|
765
|
+
}};
|
|
766
|
+
return m;
|
|
767
|
+
|
|
768
|
+
});
|
|
769
|
+
f25.cljs$lang$maxFixedArity = 2;
|
|
770
|
+
return f25;
|
|
771
|
+
|
|
772
|
+
})();
|
|
773
|
+
var apply_defaults = (() => {
|
|
774
|
+
const f33 = (function (...args34) {
|
|
775
|
+
const G__351 = args34.length;
|
|
776
|
+
switch (G__351) {case 1:
|
|
777
|
+
return f33.cljs$core$IFn$_invoke$arity$1(args34[0]);
|
|
778
|
+
|
|
779
|
+
break;
|
|
780
|
+
case 2:
|
|
781
|
+
return f33.cljs$core$IFn$_invoke$arity$2(args34[0], args34[1]);
|
|
782
|
+
|
|
783
|
+
break;
|
|
784
|
+
default:
|
|
785
|
+
throw (new Error(`${"Invalid arity: "}${args34.length??''}`))};
|
|
786
|
+
|
|
787
|
+
});
|
|
788
|
+
f33.cljs$core$IFn$_invoke$arity$1 = (function (m) {
|
|
789
|
+
return apply_defaults(m, ({}));
|
|
790
|
+
|
|
791
|
+
});
|
|
792
|
+
f33.cljs$core$IFn$_invoke$arity$2 = (function (m, opts) {
|
|
793
|
+
const opts3 = resolve_opts(opts);
|
|
794
|
+
const exec_args4 = squint_core.get(opts3, "exec-args");
|
|
795
|
+
const inherited5 = squint_core.get(opts3, "babashka.cli/dispatch-inherited");
|
|
796
|
+
if (squint_core.truth_((() => {
|
|
797
|
+
const or__23664__auto__6 = exec_args4;
|
|
798
|
+
if (squint_core.truth_(or__23664__auto__6)) {
|
|
799
|
+
return or__23664__auto__6} else {
|
|
800
|
+
return inherited5};
|
|
801
|
+
|
|
802
|
+
})())) {
|
|
803
|
+
return squint_core.with_meta(squint_core.merge(exec_args4, inherited5, m), squint_core.meta(m))} else {
|
|
804
|
+
return m};
|
|
805
|
+
|
|
806
|
+
});
|
|
807
|
+
f33.cljs$lang$maxFixedArity = 2;
|
|
808
|
+
return f33;
|
|
809
|
+
|
|
810
|
+
})();
|
|
811
|
+
var parse_opts_STAR_ = function (args, p__36) {
|
|
812
|
+
const map__12 = p__36;
|
|
813
|
+
const opts3 = map__12;
|
|
814
|
+
const coerce4 = squint_core.get(map__12, "coerce");
|
|
815
|
+
const collect5 = squint_core.get(map__12, "collect");
|
|
816
|
+
const no_keyword_opts6 = squint_core.get(map__12, "no-keyword-opts");
|
|
817
|
+
const repeated_opts7 = squint_core.get(map__12, "repeated-opts");
|
|
818
|
+
const parse_opts16 = opts3;
|
|
819
|
+
const aliases17 = (() => {
|
|
820
|
+
const or__23664__auto__18 = squint_core.get(parse_opts16, "alias");
|
|
821
|
+
if (squint_core.truth_(or__23664__auto__18)) {
|
|
822
|
+
return or__23664__auto__18} else {
|
|
823
|
+
return squint_core.get(parse_opts16, "aliases")};
|
|
824
|
+
|
|
825
|
+
})();
|
|
826
|
+
const spec19 = squint_core.get(parse_opts16, "spec");
|
|
827
|
+
const spec_map20 = ((squint_core.truth_(squint_core.map_QMARK_(spec19))) ? (spec19) : (((squint_core.truth_(spec19)) ? (squint_core.into(({}), spec19)) : (null))));
|
|
828
|
+
const alias_keys21 = squint_core.set(squint_core.concat(squint_core.keys(aliases17), squint_core.keep("alias", squint_core.vals(spec_map20))));
|
|
829
|
+
const known_keys22 = squint_core.set(squint_core.concat(squint_core.keys(spec_map20), squint_core.vals(aliases17), squint_core.keys(coerce4)));
|
|
830
|
+
const expects_bool_val_QMARK_23 = (function (opt_key) {
|
|
831
|
+
return squint_core.get((new Set (["boolean", "bool"])), coerce_coerce_fn(squint_core.get(coerce4, opt_key)));
|
|
832
|
+
|
|
833
|
+
});
|
|
834
|
+
const track_ivs24 = (function (implicit_values, current_opt, added) {
|
|
835
|
+
if (!squint_core._EQ_(current_opt, added)) {
|
|
836
|
+
return squint_core.assoc(implicit_values, current_opt, true)} else {
|
|
837
|
+
return implicit_values};
|
|
838
|
+
|
|
839
|
+
});
|
|
840
|
+
const track_kpo25 = (function (kpo, opt) {
|
|
841
|
+
if (squint_core.truth_((() => {
|
|
842
|
+
const and__23691__auto__26 = opt;
|
|
843
|
+
if (squint_core.truth_(and__23691__auto__26)) {
|
|
844
|
+
return squint_core.not(squint_core.some((new Set ([opt])), kpo))} else {
|
|
845
|
+
return and__23691__auto__26};
|
|
846
|
+
|
|
847
|
+
})())) {
|
|
848
|
+
return squint_core.conj(kpo, opt)} else {
|
|
849
|
+
return kpo};
|
|
850
|
+
|
|
851
|
+
});
|
|
852
|
+
const stamp27 = (function (m, k, lit) {
|
|
853
|
+
if (squint_core.truth_(lit)) {
|
|
854
|
+
return squint_core.vary_meta(m, squint_core.assoc_in, ["babashka.cli/opt->flag", k], lit)} else {
|
|
855
|
+
return m};
|
|
856
|
+
|
|
857
|
+
});
|
|
858
|
+
const map__828 = parse_cmds(args);
|
|
859
|
+
const leading_pos_args29 = squint_core.get(map__828, "cmds");
|
|
860
|
+
const args30 = squint_core.get(map__828, "args");
|
|
861
|
+
const map__931 = (() => {
|
|
862
|
+
const temp__23189__auto__32 = (() => {
|
|
863
|
+
const or__23664__auto__33 = squint_core.get(parse_opts16, "args->opts");
|
|
864
|
+
if (squint_core.truth_(or__23664__auto__33)) {
|
|
865
|
+
return or__23664__auto__33} else {
|
|
866
|
+
return squint_core.get(parse_opts16, "cmds-opts")};
|
|
867
|
+
|
|
868
|
+
})();
|
|
869
|
+
if (squint_core.truth_(temp__23189__auto__32)) {
|
|
870
|
+
const a__GT_o34 = temp__23189__auto__32;
|
|
871
|
+
return args__GT_opts(leading_pos_args29, a__GT_o34, squint_core.get(parse_opts16, "babashka.cli/dispatch-tree-ignored-args"));
|
|
872
|
+
} else {
|
|
873
|
+
return ({"args->opts": null, "args": args30})};
|
|
874
|
+
|
|
875
|
+
})();
|
|
876
|
+
const new_leading_pos_args35 = squint_core.get(map__931, "args");
|
|
877
|
+
const a__GT_o36 = squint_core.get(map__931, "args->opts");
|
|
878
|
+
const vec__1037 = ((!squint_core._EQ_(new_leading_pos_args35, args30)) ? ([null, squint_core.concat(new_leading_pos_args35, args30)]) : ([leading_pos_args29, args30]));
|
|
879
|
+
const leading_pos_args38 = squint_core.nth(vec__1037, 0, null);
|
|
880
|
+
const args39 = squint_core.nth(vec__1037, 1, null);
|
|
881
|
+
const vec__1340 = ((squint_core.truth_((() => {
|
|
882
|
+
const and__23691__auto__41 = squint_core.get(parse_opts16, "babashka.cli/dispatch-tree");
|
|
883
|
+
if (squint_core.truth_(and__23691__auto__41)) {
|
|
884
|
+
return squint_core.seq(leading_pos_args38)} else {
|
|
885
|
+
return and__23691__auto__41};
|
|
886
|
+
|
|
887
|
+
})())) ? ([squint_core.vary_meta(({}), squint_core.assoc_in, ["org.babashka/cli", "args"], squint_core.into(squint_core.vec(leading_pos_args38), args39)), null, null, (new Set ([])), []]) : ((() => {
|
|
888
|
+
let acc42 = ({});
|
|
889
|
+
let recur_action43 = null;
|
|
890
|
+
let open_opt44 = null;
|
|
891
|
+
let valued_opt45 = null;
|
|
892
|
+
let mode46 = ((squint_core.truth_(no_keyword_opts6)) ? ("hyphens") : (null));
|
|
893
|
+
let args47 = squint_core.seq(args39);
|
|
894
|
+
let a__GT_o48 = a__GT_o36;
|
|
895
|
+
let implicit_values49 = ({});
|
|
896
|
+
let opt_parse_order50 = [];
|
|
897
|
+
while(true){
|
|
898
|
+
if (squint_core.not(args47)) {
|
|
899
|
+
return [acc42, open_opt44, valued_opt45, implicit_values49, opt_parse_order50]} else {
|
|
900
|
+
const raw_arg51 = squint_core.first(args47);
|
|
901
|
+
const opt_injected_QMARK_52 = (() => {
|
|
902
|
+
const c__23554__auto__53 = Injected;
|
|
903
|
+
const x__23555__auto__54 = raw_arg51;
|
|
904
|
+
const ret__23556__auto__55 = (x__23555__auto__54 instanceof c__23554__auto__53);
|
|
905
|
+
return ret__23556__auto__55;
|
|
906
|
+
|
|
907
|
+
})();
|
|
908
|
+
const raw_arg56 = ((squint_core.truth_(opt_injected_QMARK_52)) ? (raw_arg51.opt) : (raw_arg51));
|
|
909
|
+
if (squint_core.truth_(opt_injected_QMARK_52)) {
|
|
910
|
+
let G__57 = maybe_close_open_opt(acc42, open_opt44, valued_opt45, null);
|
|
911
|
+
let G__58 = "found-injected-opt";
|
|
912
|
+
let G__59 = raw_arg56;
|
|
913
|
+
let G__60 = valued_opt45;
|
|
914
|
+
let G__61 = mode46;
|
|
915
|
+
let G__62 = squint_core.next(args47);
|
|
916
|
+
let G__63 = a__GT_o48;
|
|
917
|
+
let G__64 = track_ivs24(implicit_values49, open_opt44, valued_opt45);
|
|
918
|
+
let G__65 = track_kpo25(opt_parse_order50, raw_arg56);
|
|
919
|
+
acc42 = G__57;
|
|
920
|
+
recur_action43 = G__58;
|
|
921
|
+
open_opt44 = G__59;
|
|
922
|
+
valued_opt45 = G__60;
|
|
923
|
+
mode46 = G__61;
|
|
924
|
+
args47 = G__62;
|
|
925
|
+
a__GT_o48 = G__63;
|
|
926
|
+
implicit_values49 = G__64;
|
|
927
|
+
opt_parse_order50 = G__65;
|
|
928
|
+
continue;
|
|
929
|
+
} else {
|
|
930
|
+
const arg67 = `${raw_arg56??''}`;
|
|
931
|
+
const opt_val_collector68 = collect_fn(collect5, coerce4, open_opt44);
|
|
932
|
+
const boolean_opt_QMARK_69 = expects_bool_val_QMARK_23(open_opt44);
|
|
933
|
+
const map__6670 = analyze_arg(arg67, mode46, open_opt44, boolean_opt_QMARK_69, valued_opt45, known_keys22, alias_keys21);
|
|
934
|
+
const hyphen_opt71 = squint_core.get(map__6670, "hyphen-opt");
|
|
935
|
+
const composite_opt72 = squint_core.get(map__6670, "composite-opt");
|
|
936
|
+
const kwd_opt73 = squint_core.get(map__6670, "kwd-opt");
|
|
937
|
+
const mode74 = squint_core.get(map__6670, "mode");
|
|
938
|
+
const fst_colon75 = squint_core.get(map__6670, "fst-colon");
|
|
939
|
+
if (squint_core.truth_((() => {
|
|
940
|
+
const or__23664__auto__76 = hyphen_opt71;
|
|
941
|
+
if (squint_core.truth_(or__23664__auto__76)) {
|
|
942
|
+
return or__23664__auto__76} else {
|
|
943
|
+
return kwd_opt73};
|
|
944
|
+
|
|
945
|
+
})())) {
|
|
946
|
+
const long_opt_QMARK_77 = str.starts_with_QMARK_(arg67, "--");
|
|
947
|
+
const eo_all_opts_QMARK_78 = (() => {
|
|
948
|
+
const and__23691__auto__79 = long_opt_QMARK_77;
|
|
949
|
+
if (squint_core.truth_(and__23691__auto__79)) {
|
|
950
|
+
return ("--" === arg67)} else {
|
|
951
|
+
return and__23691__auto__79};
|
|
952
|
+
|
|
953
|
+
})();
|
|
954
|
+
if (squint_core.truth_(eo_all_opts_QMARK_78)) {
|
|
955
|
+
const nargs80 = squint_core.next(args47);
|
|
956
|
+
return [(() => {
|
|
957
|
+
const G__3781 = acc42;
|
|
958
|
+
if (squint_core.truth_(nargs80)) {
|
|
959
|
+
return squint_core.vary_meta(G__3781, squint_core.assoc_in, ["org.babashka/cli", "args"], squint_core.vec(nargs80))} else {
|
|
960
|
+
return G__3781};
|
|
961
|
+
|
|
962
|
+
})(), open_opt44, valued_opt45, implicit_values49, opt_parse_order50];
|
|
963
|
+
} else {
|
|
964
|
+
const opt_name85 = ((squint_core.truth_(long_opt_QMARK_77)) ? (squint_core.subs(arg67, 2)) : (str.replace(arg67, /^(:|-|)/, "")));
|
|
965
|
+
const vec__8286 = ((squint_core.truth_(long_opt_QMARK_77)) ? (str.split(opt_name85, /=/, 2)) : ([opt_name85]));
|
|
966
|
+
const opt_name87 = squint_core.nth(vec__8286, 0, null);
|
|
967
|
+
const opt_val88 = squint_core.nth(vec__8286, 1, null);
|
|
968
|
+
const opt_kw89 = squint_core.keyword(opt_name87);
|
|
969
|
+
const opt_kw_for_alias90 = ((squint_core.truth_(long_opt_QMARK_77)) ? (null) : (squint_core.get(aliases17, opt_kw89)));
|
|
970
|
+
const parsed_opt91 = (() => {
|
|
971
|
+
const or__23664__auto__92 = opt_kw_for_alias90;
|
|
972
|
+
if (squint_core.truth_(or__23664__auto__92)) {
|
|
973
|
+
return or__23664__auto__92} else {
|
|
974
|
+
return opt_kw89};
|
|
975
|
+
|
|
976
|
+
})();
|
|
977
|
+
const literal_opt93 = ((squint_core.truth_(long_opt_QMARK_77)) ? (`--${opt_name87??''}`) : (arg67));
|
|
978
|
+
if (squint_core.truth_(opt_val88)) {
|
|
979
|
+
let G__94 = stamp27(maybe_close_open_opt(acc42, open_opt44, valued_opt45, opt_val_collector68), parsed_opt91, literal_opt93);
|
|
980
|
+
let G__95 = "injected-bound-val";
|
|
981
|
+
let G__96 = parsed_opt91;
|
|
982
|
+
let G__97 = null;
|
|
983
|
+
let G__98 = mode74;
|
|
984
|
+
let G__99 = squint_core.cons(opt_val88, squint_core.rest(args47));
|
|
985
|
+
let G__100 = a__GT_o48;
|
|
986
|
+
let G__101 = track_ivs24(implicit_values49, open_opt44, valued_opt45);
|
|
987
|
+
let G__102 = track_kpo25(opt_parse_order50, parsed_opt91);
|
|
988
|
+
acc42 = G__94;
|
|
989
|
+
recur_action43 = G__95;
|
|
990
|
+
open_opt44 = G__96;
|
|
991
|
+
valued_opt45 = G__97;
|
|
992
|
+
mode46 = G__98;
|
|
993
|
+
args47 = G__99;
|
|
994
|
+
a__GT_o48 = G__100;
|
|
995
|
+
implicit_values49 = G__101;
|
|
996
|
+
opt_parse_order50 = G__102;
|
|
997
|
+
continue;
|
|
998
|
+
} else {
|
|
999
|
+
const next_args103 = squint_core.next(args47);
|
|
1000
|
+
const next_arg104 = squint_core.first(next_args103);
|
|
1001
|
+
const next_arg_info105 = analyze_arg(next_arg104, mode74, open_opt44, boolean_opt_QMARK_69, valued_opt45, known_keys22, alias_keys21);
|
|
1002
|
+
const negated_opt_QMARK_106 = ((squint_core.truth_(squint_core.contains_QMARK_(known_keys22, parsed_opt91))) ? (null) : (str.starts_with_QMARK_(`${parsed_opt91??''}`, "no-")));
|
|
1003
|
+
if (squint_core.truth_((() => {
|
|
1004
|
+
const or__23664__auto__107 = squint_core.get(next_arg_info105, "hyphen-opt");
|
|
1005
|
+
if (squint_core.truth_(or__23664__auto__107)) {
|
|
1006
|
+
return or__23664__auto__107} else {
|
|
1007
|
+
const or__23664__auto__108 = squint_core.empty_QMARK_(next_args103);
|
|
1008
|
+
if (squint_core.truth_(or__23664__auto__108)) {
|
|
1009
|
+
return or__23664__auto__108} else {
|
|
1010
|
+
return negated_opt_QMARK_106};
|
|
1011
|
+
};
|
|
1012
|
+
|
|
1013
|
+
})())) {
|
|
1014
|
+
if (squint_core.truth_((squint_core.not(opt_kw_for_alias90) && composite_opt72))) {
|
|
1015
|
+
const expanded109 = squint_core.mapcat((function (c) {
|
|
1016
|
+
return [`-${c??''}`, true];
|
|
1017
|
+
|
|
1018
|
+
}), squint_core.name(parsed_opt91));
|
|
1019
|
+
let G__110 = acc42;
|
|
1020
|
+
let G__111 = "injected-expanded-composite";
|
|
1021
|
+
let G__112 = null;
|
|
1022
|
+
let G__113 = null;
|
|
1023
|
+
let G__114 = mode74;
|
|
1024
|
+
let G__115 = squint_core.concat(expanded109, next_args103);
|
|
1025
|
+
let G__116 = a__GT_o48;
|
|
1026
|
+
let G__117 = implicit_values49;
|
|
1027
|
+
let G__118 = opt_parse_order50;
|
|
1028
|
+
acc42 = G__110;
|
|
1029
|
+
recur_action43 = G__111;
|
|
1030
|
+
open_opt44 = G__112;
|
|
1031
|
+
valued_opt45 = G__113;
|
|
1032
|
+
mode46 = G__114;
|
|
1033
|
+
args47 = G__115;
|
|
1034
|
+
a__GT_o48 = G__116;
|
|
1035
|
+
implicit_values49 = G__117;
|
|
1036
|
+
opt_parse_order50 = G__118;
|
|
1037
|
+
continue;
|
|
1038
|
+
} else {
|
|
1039
|
+
const parsed_opt119 = ((squint_core.truth_(negated_opt_QMARK_106)) ? (squint_core.keyword(str.replace(`${parsed_opt91??''}`, "no-", ""))) : (parsed_opt91));
|
|
1040
|
+
let G__120 = stamp27(maybe_close_open_opt(acc42, open_opt44, valued_opt45, opt_val_collector68), parsed_opt119, literal_opt93);
|
|
1041
|
+
let G__121 = "injected-implicit-bool";
|
|
1042
|
+
let G__122 = parsed_opt119;
|
|
1043
|
+
let G__123 = valued_opt45;
|
|
1044
|
+
let G__124 = mode74;
|
|
1045
|
+
let G__125 = squint_core.cons(squint_core.not(negated_opt_QMARK_106), next_args103);
|
|
1046
|
+
let G__126 = a__GT_o48;
|
|
1047
|
+
let G__127 = track_ivs24(implicit_values49, open_opt44, valued_opt45);
|
|
1048
|
+
let G__128 = track_kpo25(opt_parse_order50, parsed_opt119);
|
|
1049
|
+
acc42 = G__120;
|
|
1050
|
+
recur_action43 = G__121;
|
|
1051
|
+
open_opt44 = G__122;
|
|
1052
|
+
valued_opt45 = G__123;
|
|
1053
|
+
mode46 = G__124;
|
|
1054
|
+
args47 = G__125;
|
|
1055
|
+
a__GT_o48 = G__126;
|
|
1056
|
+
implicit_values49 = G__127;
|
|
1057
|
+
opt_parse_order50 = G__128;
|
|
1058
|
+
continue;
|
|
1059
|
+
}} else {
|
|
1060
|
+
let G__129 = stamp27(maybe_close_open_opt(acc42, open_opt44, valued_opt45, opt_val_collector68), parsed_opt91, literal_opt93);
|
|
1061
|
+
let G__130 = "found-opt-with-unparsed-val";
|
|
1062
|
+
let G__131 = parsed_opt91;
|
|
1063
|
+
let G__132 = null;
|
|
1064
|
+
let G__133 = mode74;
|
|
1065
|
+
let G__134 = next_args103;
|
|
1066
|
+
let G__135 = a__GT_o48;
|
|
1067
|
+
let G__136 = track_ivs24(implicit_values49, open_opt44, valued_opt45);
|
|
1068
|
+
let G__137 = track_kpo25(opt_parse_order50, parsed_opt91);
|
|
1069
|
+
acc42 = G__129;
|
|
1070
|
+
recur_action43 = G__130;
|
|
1071
|
+
open_opt44 = G__131;
|
|
1072
|
+
valued_opt45 = G__132;
|
|
1073
|
+
mode46 = G__133;
|
|
1074
|
+
args47 = G__134;
|
|
1075
|
+
a__GT_o48 = G__135;
|
|
1076
|
+
implicit_values49 = G__136;
|
|
1077
|
+
opt_parse_order50 = G__137;
|
|
1078
|
+
continue;
|
|
1079
|
+
};
|
|
1080
|
+
};
|
|
1081
|
+
};
|
|
1082
|
+
} else {
|
|
1083
|
+
const done_parsing_options_QMARK_138 = (() => {
|
|
1084
|
+
const or__23664__auto__139 = (() => {
|
|
1085
|
+
const and__23691__auto__140 = boolean_opt_QMARK_69;
|
|
1086
|
+
if (squint_core.truth_(and__23691__auto__140)) {
|
|
1087
|
+
return (!("true" === arg67) && !("false" === arg67))} else {
|
|
1088
|
+
return and__23691__auto__140};
|
|
1089
|
+
|
|
1090
|
+
})();
|
|
1091
|
+
if (squint_core.truth_(or__23664__auto__139)) {
|
|
1092
|
+
return or__23664__auto__139} else {
|
|
1093
|
+
return (squint_core._EQ_(valued_opt45, open_opt44) && (() => {
|
|
1094
|
+
const or__23664__auto__141 = squint_core.not(opt_val_collector68);
|
|
1095
|
+
if (or__23664__auto__141) {
|
|
1096
|
+
return or__23664__auto__141} else {
|
|
1097
|
+
const or__23664__auto__142 = repeated_opts7;
|
|
1098
|
+
if (squint_core.truth_(or__23664__auto__142)) {
|
|
1099
|
+
return or__23664__auto__142} else {
|
|
1100
|
+
return squint_core.contains_QMARK_(squint_core.get(parse_opts16, "babashka.cli/dispatch-tree-ignored-args"), squint_core.first(args47))};
|
|
1101
|
+
};
|
|
1102
|
+
|
|
1103
|
+
})())};
|
|
1104
|
+
|
|
1105
|
+
})();
|
|
1106
|
+
if (squint_core.truth_(done_parsing_options_QMARK_138)) {
|
|
1107
|
+
const map__143144 = ((squint_core.truth_((() => {
|
|
1108
|
+
const and__23691__auto__145 = args47;
|
|
1109
|
+
if (squint_core.truth_(and__23691__auto__145)) {
|
|
1110
|
+
return a__GT_o48} else {
|
|
1111
|
+
return and__23691__auto__145};
|
|
1112
|
+
|
|
1113
|
+
})())) ? (args__GT_opts(args47, a__GT_o48, squint_core.get(parse_opts16, "babashka.cli/dispatch-tree-ignored-args"))) : (({"args": args47})));
|
|
1114
|
+
const new_trailing_pos_args146 = squint_core.get(map__143144, "args");
|
|
1115
|
+
const a__GT_o147 = squint_core.get(map__143144, "args->opts");
|
|
1116
|
+
const new_args_QMARK_148 = !squint_core._EQ_(args47, new_trailing_pos_args146);
|
|
1117
|
+
if (new_args_QMARK_148) {
|
|
1118
|
+
let G__149 = acc42;
|
|
1119
|
+
let G__150 = "injected-trailing-args-to-opts";
|
|
1120
|
+
let G__151 = open_opt44;
|
|
1121
|
+
let G__152 = valued_opt45;
|
|
1122
|
+
let G__153 = mode74;
|
|
1123
|
+
let G__154 = new_trailing_pos_args146;
|
|
1124
|
+
let G__155 = a__GT_o147;
|
|
1125
|
+
let G__156 = implicit_values49;
|
|
1126
|
+
let G__157 = opt_parse_order50;
|
|
1127
|
+
acc42 = G__149;
|
|
1128
|
+
recur_action43 = G__150;
|
|
1129
|
+
open_opt44 = G__151;
|
|
1130
|
+
valued_opt45 = G__152;
|
|
1131
|
+
mode46 = G__153;
|
|
1132
|
+
args47 = G__154;
|
|
1133
|
+
a__GT_o48 = G__155;
|
|
1134
|
+
implicit_values49 = G__156;
|
|
1135
|
+
opt_parse_order50 = G__157;
|
|
1136
|
+
continue;
|
|
1137
|
+
} else {
|
|
1138
|
+
return [squint_core.vary_meta(acc42, squint_core.assoc_in, ["org.babashka/cli", "args"], squint_core.vec(args47)), open_opt44, valued_opt45, implicit_values49, opt_parse_order50]};
|
|
1139
|
+
} else {
|
|
1140
|
+
const opt158 = ((squint_core.truth_((("keywords" === mode74) && fst_colon75))) ? (null) : (open_opt44));
|
|
1141
|
+
let G__159 = add_val_to_opt(acc42, open_opt44, opt_val_collector68, arg67);
|
|
1142
|
+
let G__160 = "added-opt-and-val";
|
|
1143
|
+
let G__161 = opt158;
|
|
1144
|
+
let G__162 = opt158;
|
|
1145
|
+
let G__163 = mode74;
|
|
1146
|
+
let G__164 = squint_core.next(args47);
|
|
1147
|
+
let G__165 = a__GT_o48;
|
|
1148
|
+
let G__166 = (() => {
|
|
1149
|
+
const G__38167 = implicit_values49;
|
|
1150
|
+
if (squint_core.truth_(squint_core.boolean_QMARK_(raw_arg56))) {
|
|
1151
|
+
return ({...G__38167,[open_opt44]:raw_arg56})} else {
|
|
1152
|
+
return G__38167};
|
|
1153
|
+
|
|
1154
|
+
})();
|
|
1155
|
+
let G__168 = opt_parse_order50;
|
|
1156
|
+
acc42 = G__159;
|
|
1157
|
+
recur_action43 = G__160;
|
|
1158
|
+
open_opt44 = G__161;
|
|
1159
|
+
valued_opt45 = G__162;
|
|
1160
|
+
mode46 = G__163;
|
|
1161
|
+
args47 = G__164;
|
|
1162
|
+
a__GT_o48 = G__165;
|
|
1163
|
+
implicit_values49 = G__166;
|
|
1164
|
+
opt_parse_order50 = G__168;
|
|
1165
|
+
continue;
|
|
1166
|
+
};
|
|
1167
|
+
};
|
|
1168
|
+
};
|
|
1169
|
+
};
|
|
1170
|
+
;break;
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
})()));
|
|
1174
|
+
const parsed169 = squint_core.nth(vec__1340, 0, null);
|
|
1175
|
+
const last_open_opt170 = squint_core.nth(vec__1340, 1, null);
|
|
1176
|
+
const last_valued_opt171 = squint_core.nth(vec__1340, 2, null);
|
|
1177
|
+
const implicit_values172 = squint_core.nth(vec__1340, 3, null);
|
|
1178
|
+
const key_parse_order173 = squint_core.nth(vec__1340, 4, null);
|
|
1179
|
+
const implicit_values174 = track_ivs24(implicit_values172, last_open_opt170, last_valued_opt171);
|
|
1180
|
+
const opt_val_collector175 = collect_fn(collect5, coerce4, last_open_opt170);
|
|
1181
|
+
const parsed176 = (() => {
|
|
1182
|
+
const G__39177 = maybe_close_open_opt(parsed169, last_open_opt170, last_valued_opt171, opt_val_collector175);
|
|
1183
|
+
if (squint_core.truth_((() => {
|
|
1184
|
+
const and__23691__auto__178 = squint_core.seq(leading_pos_args38);
|
|
1185
|
+
if (squint_core.truth_(and__23691__auto__178)) {
|
|
1186
|
+
return squint_core.not(squint_core.get(parse_opts16, "babashka.cli/dispatch-tree"))} else {
|
|
1187
|
+
return and__23691__auto__178};
|
|
1188
|
+
|
|
1189
|
+
})())) {
|
|
1190
|
+
return squint_core.vary_meta(G__39177, squint_core.update_in, ["org.babashka/cli", "args"], (function (args) {
|
|
1191
|
+
return squint_core.into(squint_core.vec(leading_pos_args38), args);
|
|
1192
|
+
|
|
1193
|
+
}))} else {
|
|
1194
|
+
return G__39177};
|
|
1195
|
+
|
|
1196
|
+
})();
|
|
1197
|
+
return squint_core.vary_meta(parsed176, squint_core.assoc, "babashka.cli/implicit-values", implicit_values174, "babashka.cli/keys-order", key_parse_order173);
|
|
1198
|
+
|
|
1199
|
+
};
|
|
1200
|
+
var parse_opts = (() => {
|
|
1201
|
+
const f40 = (function (...args41) {
|
|
1202
|
+
const G__421 = args41.length;
|
|
1203
|
+
switch (G__421) {case 1:
|
|
1204
|
+
return f40.cljs$core$IFn$_invoke$arity$1(args41[0]);
|
|
1205
|
+
|
|
1206
|
+
break;
|
|
1207
|
+
case 2:
|
|
1208
|
+
return f40.cljs$core$IFn$_invoke$arity$2(args41[0], args41[1]);
|
|
1209
|
+
|
|
1210
|
+
break;
|
|
1211
|
+
default:
|
|
1212
|
+
throw (new Error(`${"Invalid arity: "}${args41.length??''}`))};
|
|
1213
|
+
|
|
1214
|
+
});
|
|
1215
|
+
f40.cljs$core$IFn$_invoke$arity$1 = (function (args) {
|
|
1216
|
+
return parse_opts(args, ({}));
|
|
1217
|
+
|
|
1218
|
+
});
|
|
1219
|
+
f40.cljs$core$IFn$_invoke$arity$2 = (function (args, opts) {
|
|
1220
|
+
const opts3 = resolve_opts(opts);
|
|
1221
|
+
const parsed4 = parse_opts_STAR_(args, opts3);
|
|
1222
|
+
const coerced5 = coerce_opts(parsed4, ({"coerce": squint_core.get(opts3, "coerce"), "spec": squint_core.get(opts3, "spec"), "error-fn": squint_core.get(opts3, "error-fn"), "babashka.cli/auto-coerce": true, "babashka.cli/resolved": true}));
|
|
1223
|
+
const coerced6 = apply_defaults(coerced5, opts3);
|
|
1224
|
+
const validated7 = validate_opts(coerced6, opts3);
|
|
1225
|
+
return squint_core.vary_meta(validated7, squint_core.dissoc, "babashka.cli/implicit-values", "babashka.cli/keys-order", "babashka.cli/opt->flag");
|
|
1226
|
+
|
|
1227
|
+
});
|
|
1228
|
+
f40.cljs$lang$maxFixedArity = 2;
|
|
1229
|
+
return f40;
|
|
1230
|
+
|
|
1231
|
+
})();
|
|
1232
|
+
var parse_args = (() => {
|
|
1233
|
+
const f43 = (function (...args44) {
|
|
1234
|
+
const G__451 = args44.length;
|
|
1235
|
+
switch (G__451) {case 1:
|
|
1236
|
+
return f43.cljs$core$IFn$_invoke$arity$1(args44[0]);
|
|
1237
|
+
|
|
1238
|
+
break;
|
|
1239
|
+
case 2:
|
|
1240
|
+
return f43.cljs$core$IFn$_invoke$arity$2(args44[0], args44[1]);
|
|
1241
|
+
|
|
1242
|
+
break;
|
|
1243
|
+
default:
|
|
1244
|
+
throw (new Error(`${"Invalid arity: "}${args44.length??''}`))};
|
|
1245
|
+
|
|
1246
|
+
});
|
|
1247
|
+
f43.cljs$core$IFn$_invoke$arity$1 = (function (args) {
|
|
1248
|
+
return parse_args(args, ({}));
|
|
1249
|
+
|
|
1250
|
+
});
|
|
1251
|
+
f43.cljs$core$IFn$_invoke$arity$2 = (function (args, opts) {
|
|
1252
|
+
const opts3 = parse_opts(args, opts);
|
|
1253
|
+
const cli_opts4 = squint_core.get(squint_core.meta(opts3), "org.babashka/cli");
|
|
1254
|
+
return squint_core.assoc(cli_opts4, "opts", squint_core.dissoc(opts3, "org.babashka/cli"));
|
|
1255
|
+
|
|
1256
|
+
});
|
|
1257
|
+
f43.cljs$lang$maxFixedArity = 2;
|
|
1258
|
+
return f43;
|
|
1259
|
+
|
|
1260
|
+
})();
|
|
1261
|
+
var str_width = function (s) {
|
|
1262
|
+
const strip_escape_codes1 = (function (_PERCENT_1) {
|
|
1263
|
+
return str.replace(_PERCENT_1, squint_core.re_pattern("(\\x9B|\\x1B\\[)[0-?]*[ -\\/]*[@-~]"), "");
|
|
1264
|
+
|
|
1265
|
+
});
|
|
1266
|
+
return squint_core.count(strip_escape_codes1(s));
|
|
1267
|
+
|
|
1268
|
+
};
|
|
1269
|
+
var pad = function (len, s) {
|
|
1270
|
+
return `${s??''}${squint_core.apply(squint_core.str, squint_core.repeat((len - str_width(s)), " "))??''}`;
|
|
1271
|
+
|
|
1272
|
+
};
|
|
1273
|
+
var pad_cells = function (rows) {
|
|
1274
|
+
const widths1 = squint_core.reduce((function (widths, row) {
|
|
1275
|
+
return squint_core.map(squint_core.max, squint_core.map(str_width, row), widths);
|
|
1276
|
+
|
|
1277
|
+
}), squint_core.repeat(0), rows);
|
|
1278
|
+
const pad_row2 = (function (row) {
|
|
1279
|
+
return squint_core.map(pad, widths1, row);
|
|
1280
|
+
|
|
1281
|
+
});
|
|
1282
|
+
return squint_core.map(pad_row2, rows);
|
|
1283
|
+
|
|
1284
|
+
};
|
|
1285
|
+
var default_width_fn = function (_cfg) {
|
|
1286
|
+
if (squint_core.truth_(((typeof process !== 'undefined') && (() => {
|
|
1287
|
+
const and__23691__auto__1 = process.stdout;
|
|
1288
|
+
if (squint_core.truth_(and__23691__auto__1)) {
|
|
1289
|
+
return squint_core.pos_int_QMARK_(process.stdout.columns)} else {
|
|
1290
|
+
return and__23691__auto__1};
|
|
1291
|
+
|
|
1292
|
+
})()))) {
|
|
1293
|
+
return process.stdout.columns;
|
|
1294
|
+
};
|
|
1295
|
+
|
|
1296
|
+
};
|
|
1297
|
+
var word_wrap = function (width, s) {
|
|
1298
|
+
return str.join("\n", squint_core.mapcat((function (line) {
|
|
1299
|
+
if ((str_width(line) <= width)) {
|
|
1300
|
+
return [line]} else {
|
|
1301
|
+
return squint_core.reduce((function (lines, word) {
|
|
1302
|
+
const cur1 = squint_core.peek(lines);
|
|
1303
|
+
if (squint_core.truth_((() => {
|
|
1304
|
+
const or__23664__auto__2 = (cur1 == null);
|
|
1305
|
+
if (or__23664__auto__2) {
|
|
1306
|
+
return or__23664__auto__2} else {
|
|
1307
|
+
return squint_core._EQ_("", cur1)};
|
|
1308
|
+
|
|
1309
|
+
})())) {
|
|
1310
|
+
return squint_core.conj(squint_core.pop(lines), word)} else {
|
|
1311
|
+
if (((str_width(cur1) + 1 + str_width(word)) <= width)) {
|
|
1312
|
+
return squint_core.conj(squint_core.pop(lines), `${cur1??''}${" "}${word??''}`)} else {
|
|
1313
|
+
return squint_core.conj(lines, word)}};
|
|
1314
|
+
|
|
1315
|
+
}), [""], str.split(line, / /))};
|
|
1316
|
+
|
|
1317
|
+
}), str.split_lines(`${s??''}`)));
|
|
1318
|
+
|
|
1319
|
+
};
|
|
1320
|
+
var wrap_last_column = function (rows, indent, divider, max_width) {
|
|
1321
|
+
const col_cnt1 = squint_core.count(squint_core.first(rows));
|
|
1322
|
+
if ((col_cnt1 === 0)) {
|
|
1323
|
+
return rows} else {
|
|
1324
|
+
const last_idx2 = (col_cnt1 - 1);
|
|
1325
|
+
const fixed_widths3 = squint_core.reduce((function (ws, row) {
|
|
1326
|
+
return squint_core.mapv(squint_core.max, ws, squint_core.map(str_width, squint_core.take(last_idx2, row)));
|
|
1327
|
+
|
|
1328
|
+
}), squint_core.vec(squint_core.repeat(last_idx2, 0)), rows);
|
|
1329
|
+
const start4 = (indent + squint_core.reduce(squint_core._PLUS_, 0, fixed_widths3) + (last_idx2 * squint_core.count(divider)));
|
|
1330
|
+
const avail5 = squint_core.max(10, (max_width - start4));
|
|
1331
|
+
return squint_core.mapv((function (row) {
|
|
1332
|
+
const v6 = squint_core.vec(row);
|
|
1333
|
+
return squint_core.assoc(v6, last_idx2, word_wrap(avail5, `${squint_core.nth(v6, last_idx2)??''}`));
|
|
1334
|
+
|
|
1335
|
+
}), rows);
|
|
1336
|
+
};
|
|
1337
|
+
|
|
1338
|
+
};
|
|
1339
|
+
var expand_multiline_cells = function (rows) {
|
|
1340
|
+
if (squint_core.truth_(squint_core.empty_QMARK_(rows))) {
|
|
1341
|
+
return []} else {
|
|
1342
|
+
const col_cnt1 = squint_core.count(squint_core.first(rows));
|
|
1343
|
+
return squint_core.mapcat((function (row) {
|
|
1344
|
+
const row_lines2 = squint_core.mapv((function (_PERCENT_1) {
|
|
1345
|
+
return str.split_lines(`${_PERCENT_1??''}`);
|
|
1346
|
+
|
|
1347
|
+
}), row);
|
|
1348
|
+
const max_lines3 = squint_core.reduce(squint_core.max, squint_core.map(squint_core.count, row_lines2));
|
|
1349
|
+
return squint_core.map((function (line_idx) {
|
|
1350
|
+
return squint_core.map((function (_PERCENT_1) {
|
|
1351
|
+
return squint_core.get_in(row_lines2, [_PERCENT_1, line_idx], "");
|
|
1352
|
+
|
|
1353
|
+
}), squint_core.range(col_cnt1));
|
|
1354
|
+
|
|
1355
|
+
}), squint_core.range(max_lines3));
|
|
1356
|
+
|
|
1357
|
+
}), rows);
|
|
1358
|
+
};
|
|
1359
|
+
|
|
1360
|
+
};
|
|
1361
|
+
var format_table = function (p__46) {
|
|
1362
|
+
const map__12 = p__46;
|
|
1363
|
+
const cfg3 = map__12;
|
|
1364
|
+
const rows4 = squint_core.get(map__12, "rows");
|
|
1365
|
+
const indent5 = squint_core.get(map__12, "indent", 2);
|
|
1366
|
+
const divider6 = squint_core.get(map__12, "divider", " ");
|
|
1367
|
+
const wrap7 = squint_core.get(map__12, "wrap", true);
|
|
1368
|
+
const max_width_fn8 = squint_core.get(map__12, "max-width-fn", default_width_fn);
|
|
1369
|
+
const rows9 = (() => {
|
|
1370
|
+
const G__4710 = rows4;
|
|
1371
|
+
if (squint_core.truth_((() => {
|
|
1372
|
+
const and__23691__auto__11 = wrap7;
|
|
1373
|
+
if (squint_core.truth_(and__23691__auto__11)) {
|
|
1374
|
+
return squint_core.seq(rows4)} else {
|
|
1375
|
+
return and__23691__auto__11};
|
|
1376
|
+
|
|
1377
|
+
})())) {
|
|
1378
|
+
return wrap_last_column(G__4710, indent5, divider6, (() => {
|
|
1379
|
+
const or__23664__auto__12 = max_width_fn8(cfg3);
|
|
1380
|
+
if (squint_core.truth_(or__23664__auto__12)) {
|
|
1381
|
+
return or__23664__auto__12} else {
|
|
1382
|
+
return 80};
|
|
1383
|
+
|
|
1384
|
+
})())} else {
|
|
1385
|
+
return G__4710};
|
|
1386
|
+
|
|
1387
|
+
})();
|
|
1388
|
+
const rows13 = pad_cells(expand_multiline_cells(rows9));
|
|
1389
|
+
const fmt_row14 = (function (leader, divider, trailer, row) {
|
|
1390
|
+
return `${leader??''}${squint_core.apply(squint_core.str, squint_core.interpose(divider, row))??''}${trailer??''}`;
|
|
1391
|
+
|
|
1392
|
+
});
|
|
1393
|
+
return str.join("\n", squint_core.map(str.trimr, squint_core.map((function (row) {
|
|
1394
|
+
return fmt_row14(squint_core.apply(squint_core.str, squint_core.repeat(indent5, " ")), divider6, "", row);
|
|
1395
|
+
|
|
1396
|
+
}), rows13)));
|
|
1397
|
+
|
|
1398
|
+
};
|
|
1399
|
+
var opts__GT_table = function (p__48) {
|
|
1400
|
+
const map__12 = p__48;
|
|
1401
|
+
const spec3 = squint_core.get(map__12, "spec");
|
|
1402
|
+
const order4 = squint_core.get(map__12, "order");
|
|
1403
|
+
const columns5 = squint_core.get(map__12, "columns");
|
|
1404
|
+
const columns6 = squint_core.set((() => {
|
|
1405
|
+
const or__23664__auto__7 = columns5;
|
|
1406
|
+
if (squint_core.truth_(or__23664__auto__7)) {
|
|
1407
|
+
return or__23664__auto__7} else {
|
|
1408
|
+
return squint_core.mapcat((function (p__49) {
|
|
1409
|
+
const vec__811 = p__49;
|
|
1410
|
+
const _12 = squint_core.nth(vec__811, 0, null);
|
|
1411
|
+
const s13 = squint_core.nth(vec__811, 1, null);
|
|
1412
|
+
return squint_core.keys(s13);
|
|
1413
|
+
|
|
1414
|
+
}), spec3)};
|
|
1415
|
+
|
|
1416
|
+
})());
|
|
1417
|
+
return squint_core.mapv((function (p__50) {
|
|
1418
|
+
const vec__1418 = p__50;
|
|
1419
|
+
const long_opt19 = squint_core.nth(vec__1418, 0, null);
|
|
1420
|
+
const map__1720 = squint_core.nth(vec__1418, 1, null);
|
|
1421
|
+
const alias21 = squint_core.get(map__1720, "alias");
|
|
1422
|
+
const default$22 = squint_core.get(map__1720, "default");
|
|
1423
|
+
const default_desc23 = squint_core.get(map__1720, "default-desc");
|
|
1424
|
+
const ref24 = squint_core.get(map__1720, "ref");
|
|
1425
|
+
const desc25 = squint_core.get(map__1720, "desc");
|
|
1426
|
+
const negatable26 = squint_core.get(map__1720, "negatable");
|
|
1427
|
+
return squint_core.keep(squint_core.identity, [((squint_core.truth_(squint_core.get(columns6, "alias"))) ? (((squint_core.truth_(alias21)) ? (`-${kw__GT_str(alias21)??''}${","}`) : (""))) : (null)), `--${((squint_core.truth_(negatable26)) ? ("[no-]") : (null))??''}${kw__GT_str(long_opt19)??''}`, ((squint_core.truth_(squint_core.get(columns6, "ref"))) ? (((squint_core.truth_(ref24)) ? (ref24) : (""))) : (null)), ((squint_core.truth_((() => {
|
|
1428
|
+
const or__23664__auto__27 = squint_core.get(columns6, "default-desc");
|
|
1429
|
+
if (squint_core.truth_(or__23664__auto__27)) {
|
|
1430
|
+
return or__23664__auto__27} else {
|
|
1431
|
+
return !(squint_core.get(columns6, "default") == null)};
|
|
1432
|
+
|
|
1433
|
+
})())) ? (`${(() => {
|
|
1434
|
+
const or__23664__auto__28 = default_desc23;
|
|
1435
|
+
if (squint_core.truth_(or__23664__auto__28)) {
|
|
1436
|
+
return or__23664__auto__28} else {
|
|
1437
|
+
const or__23664__auto__29 = `${default$22??''}`;
|
|
1438
|
+
if (or__23664__auto__29) {
|
|
1439
|
+
return or__23664__auto__29} else {
|
|
1440
|
+
return ""};
|
|
1441
|
+
};
|
|
1442
|
+
|
|
1443
|
+
})()??''}`) : (null)), ((squint_core.truth_(squint_core.get(columns6, "desc"))) ? (((squint_core.truth_(desc25)) ? (desc25) : (""))) : (null))]);
|
|
1444
|
+
|
|
1445
|
+
}), ((squint_core.truth_(squint_core.map_QMARK_(spec3))) ? ((() => {
|
|
1446
|
+
const order30 = (() => {
|
|
1447
|
+
const or__23664__auto__31 = order4;
|
|
1448
|
+
if (squint_core.truth_(or__23664__auto__31)) {
|
|
1449
|
+
return or__23664__auto__31} else {
|
|
1450
|
+
return squint_core.keys(spec3)};
|
|
1451
|
+
|
|
1452
|
+
})();
|
|
1453
|
+
return squint_core.map((function (k) {
|
|
1454
|
+
return [k, squint_core.get(spec3, k)];
|
|
1455
|
+
|
|
1456
|
+
}), order30);
|
|
1457
|
+
|
|
1458
|
+
})()) : (spec3)));
|
|
1459
|
+
|
|
1460
|
+
};
|
|
1461
|
+
var opts__GT_help_rows = function (p__51) {
|
|
1462
|
+
const map__12 = p__51;
|
|
1463
|
+
const spec3 = squint_core.get(map__12, "spec");
|
|
1464
|
+
const order4 = squint_core.get(map__12, "order");
|
|
1465
|
+
const required5 = squint_core.get(map__12, "required");
|
|
1466
|
+
const entries6 = ((squint_core.truth_(squint_core.map_QMARK_(spec3))) ? (squint_core.map((function (k) {
|
|
1467
|
+
return [k, squint_core.get(spec3, k)];
|
|
1468
|
+
|
|
1469
|
+
}), (() => {
|
|
1470
|
+
const or__23664__auto__7 = order4;
|
|
1471
|
+
if (squint_core.truth_(or__23664__auto__7)) {
|
|
1472
|
+
return or__23664__auto__7} else {
|
|
1473
|
+
return squint_core.keys(spec3)};
|
|
1474
|
+
|
|
1475
|
+
})())) : (spec3));
|
|
1476
|
+
const entries8 = squint_core.remove((function (p__52) {
|
|
1477
|
+
const vec__912 = p__52;
|
|
1478
|
+
const _13 = squint_core.nth(vec__912, 0, null);
|
|
1479
|
+
const v14 = squint_core.nth(vec__912, 1, null);
|
|
1480
|
+
return squint_core.get(v14, "no-doc");
|
|
1481
|
+
|
|
1482
|
+
}), entries6);
|
|
1483
|
+
const required15 = squint_core.set(required5);
|
|
1484
|
+
const short$16 = (function (p__53) {
|
|
1485
|
+
const vec__1721 = p__53;
|
|
1486
|
+
const _22 = squint_core.nth(vec__1721, 0, null);
|
|
1487
|
+
const map__2023 = squint_core.nth(vec__1721, 1, null);
|
|
1488
|
+
const alias24 = squint_core.get(map__2023, "alias");
|
|
1489
|
+
if (squint_core.truth_(alias24)) {
|
|
1490
|
+
return `-${kw__GT_str(alias24)??''}${", "}`} else {
|
|
1491
|
+
return ""};
|
|
1492
|
+
|
|
1493
|
+
});
|
|
1494
|
+
const sw25 = squint_core.transduce(squint_core.map(squint_core.comp(squint_core.count, short$16)), squint_core.max, 0, entries8);
|
|
1495
|
+
return squint_core.mapv((function (p__54, sh) {
|
|
1496
|
+
const vec__2630 = p__54;
|
|
1497
|
+
const long_opt31 = squint_core.nth(vec__2630, 0, null);
|
|
1498
|
+
const map__2932 = squint_core.nth(vec__2630, 1, null);
|
|
1499
|
+
const req33 = squint_core.get(map__2932, "require");
|
|
1500
|
+
const default$34 = squint_core.get(map__2932, "default");
|
|
1501
|
+
const default_desc35 = squint_core.get(map__2932, "default-desc");
|
|
1502
|
+
const ref36 = squint_core.get(map__2932, "ref");
|
|
1503
|
+
const desc37 = squint_core.get(map__2932, "desc");
|
|
1504
|
+
const negatable38 = squint_core.get(map__2932, "negatable");
|
|
1505
|
+
const dflt39 = (() => {
|
|
1506
|
+
const or__23664__auto__40 = default_desc35;
|
|
1507
|
+
if (squint_core.truth_(or__23664__auto__40)) {
|
|
1508
|
+
return or__23664__auto__40} else {
|
|
1509
|
+
if (!(default$34 == null)) {
|
|
1510
|
+
return `${default$34??''}`;
|
|
1511
|
+
}};
|
|
1512
|
+
|
|
1513
|
+
})();
|
|
1514
|
+
const note41 = ((squint_core.truth_((() => {
|
|
1515
|
+
const or__23664__auto__42 = req33;
|
|
1516
|
+
if (squint_core.truth_(or__23664__auto__42)) {
|
|
1517
|
+
return or__23664__auto__42} else {
|
|
1518
|
+
return squint_core.contains_QMARK_(required15, long_opt31)};
|
|
1519
|
+
|
|
1520
|
+
})())) ? ("(required)") : (((squint_core.truth_(dflt39)) ? (`${"(default: "}${dflt39??''}${")"}`) : (null))));
|
|
1521
|
+
const inv43 = `${sh??''}${squint_core.apply(squint_core.str, squint_core.repeat((sw25 - squint_core.count(sh)), " "))??''}--${((squint_core.truth_(negatable38)) ? ("[no-]") : (null))??''}${kw__GT_str(long_opt31)??''}${((squint_core.truth_(ref36)) ? (`${" "}${ref36??''}`) : (null))??''}`;
|
|
1522
|
+
const desc44 = `${desc37??''}${((squint_core.truth_(note41)) ? (`${((squint_core.truth_(squint_core.seq(desc37))) ? (" ") : (null))??''}${note41??''}`) : (null))??''}`;
|
|
1523
|
+
return [inv43, desc44];
|
|
1524
|
+
|
|
1525
|
+
}), entries8, squint_core.map(short$16, entries8));
|
|
1526
|
+
|
|
1527
|
+
};
|
|
1528
|
+
var format_opts = function (p__55) {
|
|
1529
|
+
const map__12 = p__55;
|
|
1530
|
+
const cfg3 = map__12;
|
|
1531
|
+
const indent4 = squint_core.get(map__12, "indent", 2);
|
|
1532
|
+
const wrap5 = squint_core.get(map__12, "wrap", true);
|
|
1533
|
+
const max_width_fn6 = squint_core.get(map__12, "max-width-fn", default_width_fn);
|
|
1534
|
+
return format_table(({"rows": opts__GT_help_rows(cfg3), "indent": indent4, "divider": " ", "wrap": wrap5, "max-width-fn": max_width_fn6}));
|
|
1535
|
+
|
|
1536
|
+
};
|
|
1537
|
+
var help_first_line = function (s) {
|
|
1538
|
+
if (squint_core.truth_(s)) {
|
|
1539
|
+
return squint_core.first(str.split_lines(s));
|
|
1540
|
+
};
|
|
1541
|
+
|
|
1542
|
+
};
|
|
1543
|
+
var help_description = function (s) {
|
|
1544
|
+
if (squint_core.truth_(s)) {
|
|
1545
|
+
const ls1 = squint_core.reverse(squint_core.drop_while(str.blank_QMARK_, squint_core.reverse(squint_core.drop_while(str.blank_QMARK_, squint_core.map(str.triml, str.split_lines(s))))));
|
|
1546
|
+
if (squint_core.truth_(squint_core.seq(ls1))) {
|
|
1547
|
+
return str.join("\n", ls1);
|
|
1548
|
+
};
|
|
1549
|
+
};
|
|
1550
|
+
|
|
1551
|
+
};
|
|
1552
|
+
var args__GT_opts_labels = function (args__GT_opts) {
|
|
1553
|
+
if (squint_core.truth_(squint_core.seq(args__GT_opts))) {
|
|
1554
|
+
let s1 = squint_core.seq(args__GT_opts);
|
|
1555
|
+
let acc2 = [];
|
|
1556
|
+
let prev3 = null;
|
|
1557
|
+
let n4 = 0;
|
|
1558
|
+
while(true){
|
|
1559
|
+
const k5 = squint_core.first(s1);
|
|
1560
|
+
if (squint_core.truth_((() => {
|
|
1561
|
+
const or__23664__auto__6 = (s1 == null);
|
|
1562
|
+
if (or__23664__auto__6) {
|
|
1563
|
+
return or__23664__auto__6} else {
|
|
1564
|
+
return (n4 >= 64)};
|
|
1565
|
+
|
|
1566
|
+
})())) {
|
|
1567
|
+
return acc2} else {
|
|
1568
|
+
if (squint_core._EQ_(k5, prev3)) {
|
|
1569
|
+
return squint_core.conj(squint_core.pop(acc2), `${"<"}${squint_core.name(prev3)}${">..."}`)} else {
|
|
1570
|
+
if ("else") {
|
|
1571
|
+
let G__7 = squint_core.next(s1);
|
|
1572
|
+
let G__8 = squint_core.conj(acc2, `${"<"}${squint_core.name(k5)}${">"}`);
|
|
1573
|
+
let G__9 = k5;
|
|
1574
|
+
let G__10 = (n4 + 1);
|
|
1575
|
+
s1 = G__7;
|
|
1576
|
+
acc2 = G__8;
|
|
1577
|
+
prev3 = G__9;
|
|
1578
|
+
n4 = G__10;
|
|
1579
|
+
continue;
|
|
1580
|
+
} else {
|
|
1581
|
+
return null}}};
|
|
1582
|
+
;break;
|
|
1583
|
+
}
|
|
1584
|
+
;
|
|
1585
|
+
};
|
|
1586
|
+
|
|
1587
|
+
};
|
|
1588
|
+
var cmd_children = function (node) {
|
|
1589
|
+
const m1 = squint_core.get(node, "cmd");
|
|
1590
|
+
const order2 = (() => {
|
|
1591
|
+
const or__23664__auto__3 = squint_core.get(node, "cmd-order");
|
|
1592
|
+
if (squint_core.truth_(or__23664__auto__3)) {
|
|
1593
|
+
return or__23664__auto__3} else {
|
|
1594
|
+
return squint_core.get(node, "babashka.cli/cmd-order")};
|
|
1595
|
+
|
|
1596
|
+
})();
|
|
1597
|
+
const pairs4 = ((squint_core.truth_(order2)) ? (squint_core.keep((function (k) {
|
|
1598
|
+
const temp__23259__auto__5 = squint_core.get(m1, k);
|
|
1599
|
+
if (squint_core.truth_(temp__23259__auto__5)) {
|
|
1600
|
+
const child6 = temp__23259__auto__5;
|
|
1601
|
+
return [k, child6];
|
|
1602
|
+
};
|
|
1603
|
+
|
|
1604
|
+
}), order2)) : (squint_core.map(squint_core.juxt(squint_core.key, squint_core.val), m1)));
|
|
1605
|
+
return squint_core.remove(squint_core.comp("no-doc", squint_core.second), pairs4);
|
|
1606
|
+
|
|
1607
|
+
};
|
|
1608
|
+
var help_usage_line = function (prog, node, any_options_QMARK_) {
|
|
1609
|
+
return `${"Usage: "}${prog??''}${((squint_core.truth_(any_options_QMARK_)) ? (" [options]") : (null))??''}${((squint_core.truth_(squint_core.seq(squint_core.get(node, "cmd")))) ? (" <command>") : (((squint_core.truth_(squint_core.get(node, "fn"))) ? ((() => {
|
|
1610
|
+
const temp__23259__auto__1 = args__GT_opts_labels(squint_core.get(node, "args->opts"));
|
|
1611
|
+
if (squint_core.truth_(temp__23259__auto__1)) {
|
|
1612
|
+
const labels2 = temp__23259__auto__1;
|
|
1613
|
+
return `${" "}${str.join(" ", labels2)??''}`;
|
|
1614
|
+
};
|
|
1615
|
+
|
|
1616
|
+
})()) : ((("else") ? ("") : (null))))))??''}`;
|
|
1617
|
+
|
|
1618
|
+
};
|
|
1619
|
+
var help_commands_table = function (node) {
|
|
1620
|
+
return squint_core.mapv((function (p__56) {
|
|
1621
|
+
const vec__14 = p__56;
|
|
1622
|
+
const cmd5 = squint_core.nth(vec__14, 0, null);
|
|
1623
|
+
const subnode6 = squint_core.nth(vec__14, 1, null);
|
|
1624
|
+
return [`${cmd5??''}`, (() => {
|
|
1625
|
+
const or__23664__auto__7 = help_first_line(squint_core.get(subnode6, "doc"));
|
|
1626
|
+
if (squint_core.truth_(or__23664__auto__7)) {
|
|
1627
|
+
return or__23664__auto__7} else {
|
|
1628
|
+
return ""};
|
|
1629
|
+
|
|
1630
|
+
})()];
|
|
1631
|
+
|
|
1632
|
+
}), cmd_children(node));
|
|
1633
|
+
|
|
1634
|
+
};
|
|
1635
|
+
var __GT_spec_map = function (spec) {
|
|
1636
|
+
if ((spec == null)) {
|
|
1637
|
+
return ({})} else {
|
|
1638
|
+
if (squint_core.truth_(squint_core.map_QMARK_(spec))) {
|
|
1639
|
+
return spec} else {
|
|
1640
|
+
if ("else") {
|
|
1641
|
+
return squint_core.into(({}), spec)} else {
|
|
1642
|
+
return null}}};
|
|
1643
|
+
|
|
1644
|
+
};
|
|
1645
|
+
var visible_spec_QMARK_ = function (spec) {
|
|
1646
|
+
return squint_core.boolean$(squint_core.some((function (p__57) {
|
|
1647
|
+
const vec__14 = p__57;
|
|
1648
|
+
const _5 = squint_core.nth(vec__14, 0, null);
|
|
1649
|
+
const v6 = squint_core.nth(vec__14, 1, null);
|
|
1650
|
+
return squint_core.not(squint_core.get(v6, "no-doc"));
|
|
1651
|
+
|
|
1652
|
+
}), __GT_spec_map(spec)));
|
|
1653
|
+
|
|
1654
|
+
};
|
|
1655
|
+
var render_help = function (node, p__58) {
|
|
1656
|
+
const map__12 = p__58;
|
|
1657
|
+
const prog3 = squint_core.get(map__12, "prog");
|
|
1658
|
+
const inherited4 = squint_core.get(map__12, "inherited");
|
|
1659
|
+
const parents5 = squint_core.get(map__12, "parents");
|
|
1660
|
+
const spec6 = squint_core.get(node, "spec");
|
|
1661
|
+
const order7 = squint_core.get(node, "order");
|
|
1662
|
+
const inherited8 = squint_core.apply(squint_core.dissoc, inherited4, squint_core.keys(__GT_spec_map(spec6)));
|
|
1663
|
+
const desc9 = help_description(squint_core.get(node, "doc"));
|
|
1664
|
+
const cmds10 = help_commands_table(node);
|
|
1665
|
+
const sections11 = (() => {
|
|
1666
|
+
const G__5912 = [help_usage_line(prog3, node, (() => {
|
|
1667
|
+
const or__23664__auto__13 = visible_spec_QMARK_(spec6);
|
|
1668
|
+
if (squint_core.truth_(or__23664__auto__13)) {
|
|
1669
|
+
return or__23664__auto__13} else {
|
|
1670
|
+
return visible_spec_QMARK_(inherited8)};
|
|
1671
|
+
|
|
1672
|
+
})())];
|
|
1673
|
+
const G__5914 = ((squint_core.truth_(desc9)) ? (squint_core.conj(G__5912, desc9)) : (G__5912));
|
|
1674
|
+
const G__5915 = ((squint_core.truth_(squint_core.seq(cmds10))) ? (squint_core.conj(G__5914, `${"Commands:\n"}${format_table(({"rows": cmds10, "indent": 2}))??''}`)) : (G__5914));
|
|
1675
|
+
const G__5916 = ((squint_core.truth_(visible_spec_QMARK_(spec6))) ? (squint_core.conj(G__5915, `${"Options:\n"}${format_opts((() => {
|
|
1676
|
+
const G__6017 = ({"spec": spec6, "required": squint_core.get(node, "require")});
|
|
1677
|
+
if (squint_core.truth_(order7)) {
|
|
1678
|
+
return ({...G__6017,["order"]:order7})} else {
|
|
1679
|
+
return G__6017};
|
|
1680
|
+
|
|
1681
|
+
})())??''}`)) : (G__5915));
|
|
1682
|
+
const G__5918 = ((squint_core.truth_(visible_spec_QMARK_(inherited8))) ? (squint_core.conj(G__5916, `${"Inherited options:\n"}${format_opts(({"spec": inherited8}))??''}`)) : (G__5916));
|
|
1683
|
+
const G__5919 = ((squint_core.truth_(squint_core.seq(cmds10))) ? (squint_core.conj(G__5918, `${"Run \""}${prog3??''}${" <command> --help\" for more information on a command."}`)) : (G__5918));
|
|
1684
|
+
const G__5920 = ((squint_core.truth_(squint_core.seq(parents5))) ? (squint_core.conj(G__5919, str.join("\n", squint_core.lazy((function* () {
|
|
1685
|
+
for (let G__21 of squint_core.iterable(parents5)) {
|
|
1686
|
+
const map__2223 = G__21;
|
|
1687
|
+
const p24 = squint_core.get(map__2223, "prog");
|
|
1688
|
+
const n25 = squint_core.get(map__2223, "name");
|
|
1689
|
+
yield `${"Run \""}${p24??''}${" --help\" for "}${n25??''}${" options."}`;
|
|
1690
|
+
}
|
|
1691
|
+
return null;
|
|
1692
|
+
|
|
1693
|
+
}))))) : (G__5919));
|
|
1694
|
+
if (squint_core.truth_(squint_core.get(node, "epilog"))) {
|
|
1695
|
+
return squint_core.conj(G__5920, str.trim(squint_core.get(node, "epilog")))} else {
|
|
1696
|
+
return G__5920};
|
|
1697
|
+
|
|
1698
|
+
})();
|
|
1699
|
+
return str.join("\n\n", sections11);
|
|
1700
|
+
|
|
1701
|
+
};
|
|
1702
|
+
var split = function (a, b) {
|
|
1703
|
+
const vec__14 = squint_core.split_at(squint_core.count(a), b);
|
|
1704
|
+
const prefix5 = squint_core.nth(vec__14, 0, null);
|
|
1705
|
+
const suffix6 = squint_core.nth(vec__14, 1, null);
|
|
1706
|
+
if (squint_core._EQ_(prefix5, a)) {
|
|
1707
|
+
return suffix6;
|
|
1708
|
+
};
|
|
1709
|
+
|
|
1710
|
+
};
|
|
1711
|
+
var add_table_entry = function (node, cmds, cfg) {
|
|
1712
|
+
const temp__23189__auto__1 = squint_core.seq(cmds);
|
|
1713
|
+
if (squint_core.truth_(temp__23189__auto__1)) {
|
|
1714
|
+
const vec__25 = temp__23189__auto__1;
|
|
1715
|
+
const seq__36 = squint_core.seq(vec__25);
|
|
1716
|
+
const first__47 = squint_core.first(seq__36);
|
|
1717
|
+
const seq__38 = squint_core.next(seq__36);
|
|
1718
|
+
const c9 = first__47;
|
|
1719
|
+
const cs10 = seq__38;
|
|
1720
|
+
return squint_core.update_in(squint_core.update(node, "babashka.cli/cmd-order", squint_core.fnil(squint_core.conj, []), c9), ["cmd", c9], add_table_entry, cs10, cfg);
|
|
1721
|
+
} else {
|
|
1722
|
+
const extra11 = squint_core.get(cfg, "cmd");
|
|
1723
|
+
const G__6112 = squint_core.merge(node, cfg);
|
|
1724
|
+
const G__6113 = ((squint_core.truth_(extra11)) ? (squint_core.assoc(G__6112, "cmd", squint_core.merge(squint_core.get(node, "cmd"), extra11))) : (G__6112));
|
|
1725
|
+
if (squint_core.truth_(extra11)) {
|
|
1726
|
+
return squint_core.update(G__6113, "babashka.cli/cmd-order", squint_core.fnil(squint_core.into, []), squint_core.keys(extra11))} else {
|
|
1727
|
+
return G__6113};
|
|
1728
|
+
};
|
|
1729
|
+
|
|
1730
|
+
};
|
|
1731
|
+
var normalize_node = function (node) {
|
|
1732
|
+
if (squint_core.truth_(squint_core.get(node, "cmds"))) {
|
|
1733
|
+
throw squint_core.ex_info("A tree node contains :cmds (table entry syntax): nest children under :cmd, or pass a table (vector of entries)", ({"node": node}))};
|
|
1734
|
+
const temp__23189__auto__1 = squint_core.get(node, "cmd");
|
|
1735
|
+
if (squint_core.truth_(temp__23189__auto__1)) {
|
|
1736
|
+
const m2 = temp__23189__auto__1;
|
|
1737
|
+
const recorded3 = squint_core.into([], squint_core.comp(squint_core.distinct(), squint_core.filter((function (_PERCENT_1) {
|
|
1738
|
+
return squint_core.contains_QMARK_(m2, _PERCENT_1);
|
|
1739
|
+
|
|
1740
|
+
}))), squint_core.get(node, "babashka.cli/cmd-order"));
|
|
1741
|
+
const order4 = squint_core.into(recorded3, squint_core.remove(squint_core.set(recorded3)), squint_core.keys(m2));
|
|
1742
|
+
const m_SINGLEQUOTE_5 = squint_core.reduce_kv((function (acc, k, v) {
|
|
1743
|
+
const v_SINGLEQUOTE_6 = normalize_node(v);
|
|
1744
|
+
if ((v === v_SINGLEQUOTE_6)) {
|
|
1745
|
+
return acc} else {
|
|
1746
|
+
return squint_core.assoc(acc, k, v_SINGLEQUOTE_6)};
|
|
1747
|
+
|
|
1748
|
+
}), m2, m2);
|
|
1749
|
+
const deduped7 = (() => {
|
|
1750
|
+
const temp__23259__auto__8 = squint_core.get(node, "cmd-order");
|
|
1751
|
+
if (squint_core.truth_(temp__23259__auto__8)) {
|
|
1752
|
+
const co9 = temp__23259__auto__8;
|
|
1753
|
+
return squint_core.vec(squint_core.distinct(co9));
|
|
1754
|
+
};
|
|
1755
|
+
|
|
1756
|
+
})();
|
|
1757
|
+
const G__6210 = node;
|
|
1758
|
+
const G__6211 = ((!(m2 === m_SINGLEQUOTE_5)) ? (squint_core.assoc(G__6210, "cmd", m_SINGLEQUOTE_5)) : (G__6210));
|
|
1759
|
+
const G__6212 = ((!squint_core._EQ_(order4, squint_core.get(node, "babashka.cli/cmd-order"))) ? (squint_core.assoc(G__6211, "babashka.cli/cmd-order", order4)) : (G__6211));
|
|
1760
|
+
if (squint_core.truth_((() => {
|
|
1761
|
+
const and__23691__auto__13 = deduped7;
|
|
1762
|
+
if (squint_core.truth_(and__23691__auto__13)) {
|
|
1763
|
+
return !squint_core._EQ_(deduped7, squint_core.get(node, "cmd-order"))} else {
|
|
1764
|
+
return and__23691__auto__13};
|
|
1765
|
+
|
|
1766
|
+
})())) {
|
|
1767
|
+
return squint_core.assoc(G__6212, "cmd-order", deduped7)} else {
|
|
1768
|
+
return G__6212};
|
|
1769
|
+
} else {
|
|
1770
|
+
return node};
|
|
1771
|
+
|
|
1772
|
+
};
|
|
1773
|
+
var table__GT_tree = function (table) {
|
|
1774
|
+
if (squint_core.truth_(squint_core.map_QMARK_(table))) {
|
|
1775
|
+
if (squint_core.truth_(squint_core.get(table, "cmds"))) {
|
|
1776
|
+
throw squint_core.ex_info("Expected a table (vector of entries) or a tree, got a single table entry - wrap it in a vector", ({"table": table}))} else {
|
|
1777
|
+
return normalize_node(table)}} else {
|
|
1778
|
+
return normalize_node(squint_core.reduce((function (tree, p__63) {
|
|
1779
|
+
const map__12 = p__63;
|
|
1780
|
+
const cfg3 = map__12;
|
|
1781
|
+
const cmds4 = squint_core.get(map__12, "cmds");
|
|
1782
|
+
return add_table_entry(tree, cmds4, squint_core.dissoc(cfg3, "cmds"));
|
|
1783
|
+
|
|
1784
|
+
}), ({}), table))};
|
|
1785
|
+
|
|
1786
|
+
};
|
|
1787
|
+
var deep_merge = function (a, b) {
|
|
1788
|
+
return squint_core.reduce((function (acc, k) {
|
|
1789
|
+
return squint_core.update(acc, k, (function (v) {
|
|
1790
|
+
if (squint_core.truth_(squint_core.map_QMARK_(v))) {
|
|
1791
|
+
return deep_merge(v, squint_core.get(b, k))} else {
|
|
1792
|
+
return squint_core.get(b, k)};
|
|
1793
|
+
|
|
1794
|
+
}));
|
|
1795
|
+
|
|
1796
|
+
}), a, squint_core.keys(b));
|
|
1797
|
+
|
|
1798
|
+
};
|
|
1799
|
+
var inherited_entries = function (spec, inherit_opt) {
|
|
1800
|
+
const m1 = __GT_spec_map(spec);
|
|
1801
|
+
if (squint_core.truth_(squint_core.true_QMARK_(inherit_opt))) {
|
|
1802
|
+
return m1} else {
|
|
1803
|
+
return squint_core.merge(squint_core.into(({}), squint_core.filter((function (p__64) {
|
|
1804
|
+
const vec__25 = p__64;
|
|
1805
|
+
const _6 = squint_core.nth(vec__25, 0, null);
|
|
1806
|
+
const v7 = squint_core.nth(vec__25, 1, null);
|
|
1807
|
+
const and__23691__auto__8 = squint_core.map_QMARK_(v7);
|
|
1808
|
+
if (squint_core.truth_(and__23691__auto__8)) {
|
|
1809
|
+
return squint_core.get(v7, "inherit")} else {
|
|
1810
|
+
return and__23691__auto__8};
|
|
1811
|
+
|
|
1812
|
+
}), m1)), ((squint_core.truth_(squint_core.coll_QMARK_(inherit_opt))) ? (squint_core.select_keys(m1, squint_core.set(inherit_opt))) : (null)))};
|
|
1813
|
+
|
|
1814
|
+
};
|
|
1815
|
+
var format_long_opt = function (k) {
|
|
1816
|
+
return `--${kw__GT_str(k)??''}`;
|
|
1817
|
+
|
|
1818
|
+
};
|
|
1819
|
+
var format_short_opt = function (k) {
|
|
1820
|
+
return `-${kw__GT_str(k)??''}`;
|
|
1821
|
+
|
|
1822
|
+
};
|
|
1823
|
+
var true_prefix_QMARK_ = function (prefix, s) {
|
|
1824
|
+
return ((squint_core.count(prefix) < squint_core.count(s)) && str.starts_with_QMARK_(s, prefix));
|
|
1825
|
+
|
|
1826
|
+
};
|
|
1827
|
+
var strip_prefix = function (prefix, s) {
|
|
1828
|
+
if (squint_core.truth_(str.starts_with_QMARK_(s, prefix))) {
|
|
1829
|
+
return squint_core.subs(s, squint_core.count(prefix))} else {
|
|
1830
|
+
return s};
|
|
1831
|
+
|
|
1832
|
+
};
|
|
1833
|
+
var gnu_option_QMARK_ = function (s) {
|
|
1834
|
+
const and__23691__auto__1 = s;
|
|
1835
|
+
if (squint_core.truth_(and__23691__auto__1)) {
|
|
1836
|
+
return str.starts_with_QMARK_(s, "-")} else {
|
|
1837
|
+
return and__23691__auto__1};
|
|
1838
|
+
|
|
1839
|
+
};
|
|
1840
|
+
var option_key = function (token, opts) {
|
|
1841
|
+
if (squint_core.truth_(str.starts_with_QMARK_(token, "--"))) {
|
|
1842
|
+
return squint_core.keyword(strip_prefix("--", token))} else {
|
|
1843
|
+
return squint_core.get_in(opts, ["alias", squint_core.keyword(strip_prefix("-", token))])};
|
|
1844
|
+
|
|
1845
|
+
};
|
|
1846
|
+
var bool_opt_QMARK_ = function (o, opts, known) {
|
|
1847
|
+
const k1 = option_key(o, opts);
|
|
1848
|
+
const or__23664__auto__2 = !(squint_core.get((new Set (["boolean", "bool"])), coerce_coerce_fn(squint_core.get_in(opts, ["coerce", k1]))) == null);
|
|
1849
|
+
if (or__23664__auto__2) {
|
|
1850
|
+
return or__23664__auto__2} else {
|
|
1851
|
+
const and__23691__auto__3 = k1;
|
|
1852
|
+
if (squint_core.truth_(and__23691__auto__3)) {
|
|
1853
|
+
return (squint_core.not(squint_core.contains_QMARK_(known, k1)) && str.starts_with_QMARK_(kw__GT_str(k1), "no-"))} else {
|
|
1854
|
+
return and__23691__auto__3};
|
|
1855
|
+
};
|
|
1856
|
+
|
|
1857
|
+
};
|
|
1858
|
+
var normalize_value_candidate = function (c) {
|
|
1859
|
+
if (squint_core.truth_(squint_core.map_QMARK_(c))) {
|
|
1860
|
+
return squint_core.update(c, "value", (function (v) {
|
|
1861
|
+
if (squint_core.truth_(squint_core.keyword_QMARK_(v))) {
|
|
1862
|
+
return kw__GT_str(v)} else {
|
|
1863
|
+
return `${v??''}`};
|
|
1864
|
+
|
|
1865
|
+
}))} else {
|
|
1866
|
+
if (squint_core.truth_(squint_core.keyword_QMARK_(c))) {
|
|
1867
|
+
return ({"value": kw__GT_str(c)})} else {
|
|
1868
|
+
if ("else") {
|
|
1869
|
+
return ({"value": `${c??''}`})} else {
|
|
1870
|
+
return null}}};
|
|
1871
|
+
|
|
1872
|
+
};
|
|
1873
|
+
var candidates_for_entry = function (entry, k, to_complete, parsed) {
|
|
1874
|
+
const candidates1 = ((squint_core.truth_(squint_core.get(entry, "complete-fn"))) ? (squint_core.get(entry, "complete-fn")(({"to-complete": to_complete, "opts": parsed, "option": k}))) : (((squint_core.truth_(squint_core.get(entry, "complete"))) ? (squint_core.get(entry, "complete")) : (((squint_core.truth_(squint_core.set_QMARK_(squint_core.get(entry, "validate")))) ? (squint_core.get(entry, "validate")) : (null))))));
|
|
1875
|
+
return squint_core.filter((function (_PERCENT_1) {
|
|
1876
|
+
return str.starts_with_QMARK_(squint_core.get(_PERCENT_1, "value"), to_complete);
|
|
1877
|
+
|
|
1878
|
+
}), squint_core.map(normalize_value_candidate, candidates1));
|
|
1879
|
+
|
|
1880
|
+
};
|
|
1881
|
+
var value_candidates = function (spec, opts, prev, to_complete, parsed) {
|
|
1882
|
+
const k1 = option_key(prev, opts);
|
|
1883
|
+
const entry2 = squint_core.get(spec, k1);
|
|
1884
|
+
if (squint_core.truth_((() => {
|
|
1885
|
+
const or__23664__auto__3 = squint_core.get(entry2, "complete");
|
|
1886
|
+
if (squint_core.truth_(or__23664__auto__3)) {
|
|
1887
|
+
return or__23664__auto__3} else {
|
|
1888
|
+
const or__23664__auto__4 = squint_core.get(entry2, "complete-fn");
|
|
1889
|
+
if (squint_core.truth_(or__23664__auto__4)) {
|
|
1890
|
+
return or__23664__auto__4} else {
|
|
1891
|
+
return squint_core.set_QMARK_(squint_core.get(entry2, "validate"))};
|
|
1892
|
+
};
|
|
1893
|
+
|
|
1894
|
+
})())) {
|
|
1895
|
+
return candidates_for_entry(entry2, k1, to_complete, parsed)} else {
|
|
1896
|
+
if (squint_core.truth_(squint_core.false_QMARK_(squint_core.get(entry2, "complete")))) {
|
|
1897
|
+
return null} else {
|
|
1898
|
+
return [({"file-completion": true})];
|
|
1899
|
+
}};
|
|
1900
|
+
|
|
1901
|
+
};
|
|
1902
|
+
var resolve_completion_opts = function (copts) {
|
|
1903
|
+
const spec1 = __GT_spec_map(squint_core.get(copts, "spec"));
|
|
1904
|
+
const opts2 = squint_core.assoc(((squint_core.truth_(squint_core.seq(spec1))) ? (merge_opts(copts, spec__GT_opts(spec1, copts))) : (copts)), "spec", spec1);
|
|
1905
|
+
const aliases3 = (() => {
|
|
1906
|
+
const or__23664__auto__4 = squint_core.get(opts2, "alias");
|
|
1907
|
+
if (squint_core.truth_(or__23664__auto__4)) {
|
|
1908
|
+
return or__23664__auto__4} else {
|
|
1909
|
+
return squint_core.get(opts2, "aliases")};
|
|
1910
|
+
|
|
1911
|
+
})();
|
|
1912
|
+
const known5 = squint_core.set(squint_core.concat(squint_core.keys(spec1), squint_core.keys(squint_core.get(opts2, "coerce")), squint_core.vals(aliases3)));
|
|
1913
|
+
return [opts2, aliases3, known5];
|
|
1914
|
+
|
|
1915
|
+
};
|
|
1916
|
+
var node_completion_opts = function (global_opts, inherited, node) {
|
|
1917
|
+
const parse_keys1 = ["coerce", "alias", "aliases", "collect", "no-keyword-opts", "repeated-opts"];
|
|
1918
|
+
const spec2 = deep_merge(deep_merge(__GT_spec_map(squint_core.get(global_opts, "spec")), inherited), __GT_spec_map(squint_core.get(node, "spec")));
|
|
1919
|
+
return squint_core.assoc(deep_merge(squint_core.select_keys(global_opts, parse_keys1), squint_core.select_keys(node, parse_keys1)), "spec", spec2);
|
|
1920
|
+
|
|
1921
|
+
};
|
|
1922
|
+
var repeatable_opt_QMARK_ = function (opts, k) {
|
|
1923
|
+
const or__23664__auto__1 = squint_core.coll_QMARK_(squint_core.get_in(opts, ["coerce", k]));
|
|
1924
|
+
if (squint_core.truth_(or__23664__auto__1)) {
|
|
1925
|
+
return or__23664__auto__1} else {
|
|
1926
|
+
return squint_core.contains_QMARK_(squint_core.get(opts, "collect"), k)};
|
|
1927
|
+
|
|
1928
|
+
};
|
|
1929
|
+
var safe_parse = function (args, opts) {
|
|
1930
|
+
return (() => {
|
|
1931
|
+
try{
|
|
1932
|
+
return parse_args(args, squint_core.assoc(squint_core.dissoc(opts, "exec-args"), "error-fn", (function (_) {
|
|
1933
|
+
return null;
|
|
1934
|
+
|
|
1935
|
+
}), "babashka.cli/resolved", true));
|
|
1936
|
+
}
|
|
1937
|
+
catch(_1){
|
|
1938
|
+
return ({"args": null, "opts": null});
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1941
|
+
})();
|
|
1942
|
+
|
|
1943
|
+
};
|
|
1944
|
+
var option_candidates = function (spec, opts, aliases, known, parsed, to_complete) {
|
|
1945
|
+
const used1 = squint_core.set(squint_core.remove((function (_PERCENT_1) {
|
|
1946
|
+
return repeatable_opt_QMARK_(opts, _PERCENT_1);
|
|
1947
|
+
|
|
1948
|
+
}), squint_core.keys(parsed)));
|
|
1949
|
+
return squint_core.keep((function (p__65) {
|
|
1950
|
+
const vec__25 = p__65;
|
|
1951
|
+
const token6 = squint_core.nth(vec__25, 0, null);
|
|
1952
|
+
const k7 = squint_core.nth(vec__25, 1, null);
|
|
1953
|
+
if (squint_core.truth_((squint_core.not(squint_core.get(squint_core.get(spec, k7), "no-doc")) && (squint_core.not(squint_core.get(used1, k7)) && true_prefix_QMARK_(to_complete, token6))))) {
|
|
1954
|
+
return ({"value": token6, "description": help_first_line(squint_core.get(squint_core.get(spec, k7), "desc"))});
|
|
1955
|
+
};
|
|
1956
|
+
|
|
1957
|
+
}), squint_core.concat(squint_core.map((function (k) {
|
|
1958
|
+
return [format_long_opt(k), k];
|
|
1959
|
+
|
|
1960
|
+
}), known), squint_core.map((function (p__66) {
|
|
1961
|
+
const vec__811 = p__66;
|
|
1962
|
+
const a12 = squint_core.nth(vec__811, 0, null);
|
|
1963
|
+
const l13 = squint_core.nth(vec__811, 1, null);
|
|
1964
|
+
return [format_short_opt(a12), l13];
|
|
1965
|
+
|
|
1966
|
+
}), aliases)));
|
|
1967
|
+
|
|
1968
|
+
};
|
|
1969
|
+
var command_candidates = function (node, to_complete) {
|
|
1970
|
+
return squint_core.keep((function (p__67) {
|
|
1971
|
+
const vec__14 = p__67;
|
|
1972
|
+
const cmd5 = squint_core.nth(vec__14, 0, null);
|
|
1973
|
+
const subnode6 = squint_core.nth(vec__14, 1, null);
|
|
1974
|
+
if (squint_core.truth_(true_prefix_QMARK_(to_complete, cmd5))) {
|
|
1975
|
+
return ({"value": cmd5, "description": help_first_line(squint_core.get(subnode6, "doc"))});
|
|
1976
|
+
};
|
|
1977
|
+
|
|
1978
|
+
}), cmd_children(node));
|
|
1979
|
+
|
|
1980
|
+
};
|
|
1981
|
+
var positional_candidates = function (node, spec, pos_args, parsed, to_complete) {
|
|
1982
|
+
const temp__23259__auto__1 = squint_core.seq(squint_core.get(node, "args->opts"));
|
|
1983
|
+
if (squint_core.truth_(temp__23259__auto__1)) {
|
|
1984
|
+
const a__GT_o2 = temp__23259__auto__1;
|
|
1985
|
+
const k3 = squint_core.nth(a__GT_o2, squint_core.count(pos_args), null);
|
|
1986
|
+
const entry4 = ((squint_core.truth_(k3)) ? (squint_core.get(spec, k3)) : (null));
|
|
1987
|
+
if (squint_core.truth_(k3)) {
|
|
1988
|
+
if (squint_core.truth_((() => {
|
|
1989
|
+
const or__23664__auto__5 = squint_core.get(entry4, "complete");
|
|
1990
|
+
if (squint_core.truth_(or__23664__auto__5)) {
|
|
1991
|
+
return or__23664__auto__5} else {
|
|
1992
|
+
const or__23664__auto__6 = squint_core.get(entry4, "complete-fn");
|
|
1993
|
+
if (squint_core.truth_(or__23664__auto__6)) {
|
|
1994
|
+
return or__23664__auto__6} else {
|
|
1995
|
+
return squint_core.set_QMARK_(squint_core.get(entry4, "validate"))};
|
|
1996
|
+
};
|
|
1997
|
+
|
|
1998
|
+
})())) {
|
|
1999
|
+
return candidates_for_entry(entry4, k3, to_complete, parsed)} else {
|
|
2000
|
+
if (squint_core.truth_(squint_core.false_QMARK_(squint_core.get(entry4, "complete")))) {
|
|
2001
|
+
return null} else {
|
|
2002
|
+
return [({"file-completion": true})];
|
|
2003
|
+
}};
|
|
2004
|
+
};
|
|
2005
|
+
};
|
|
2006
|
+
|
|
2007
|
+
};
|
|
2008
|
+
var descend = function (tree, global_opts, tokens) {
|
|
2009
|
+
const inherit_opt1 = squint_core.get(global_opts, "inherit");
|
|
2010
|
+
const resolve_node2 = (function (inherited, node) {
|
|
2011
|
+
return resolve_completion_opts(node_completion_opts(global_opts, inherited, node));
|
|
2012
|
+
|
|
2013
|
+
});
|
|
2014
|
+
let node3 = tree;
|
|
2015
|
+
let ropts4 = resolve_node2(({}), tree);
|
|
2016
|
+
let inherited5 = ({});
|
|
2017
|
+
let toks6 = squint_core.seq(tokens);
|
|
2018
|
+
let level7 = [];
|
|
2019
|
+
let eoo_QMARK_8 = false;
|
|
2020
|
+
while(true){
|
|
2021
|
+
const head12 = squint_core.first(toks6);
|
|
2022
|
+
const vec__913 = ropts4;
|
|
2023
|
+
const opts14 = squint_core.nth(vec__913, 0, null);
|
|
2024
|
+
const _15 = squint_core.nth(vec__913, 1, null);
|
|
2025
|
+
const known16 = squint_core.nth(vec__913, 2, null);
|
|
2026
|
+
if ((head12 == null)) {
|
|
2027
|
+
return [ropts4, node3, level7, eoo_QMARK_8]} else {
|
|
2028
|
+
if (("--" === head12)) {
|
|
2029
|
+
let G__17 = node3;
|
|
2030
|
+
let G__18 = ropts4;
|
|
2031
|
+
let G__19 = inherited5;
|
|
2032
|
+
let G__20 = squint_core.next(toks6);
|
|
2033
|
+
let G__21 = squint_core.conj(level7, head12);
|
|
2034
|
+
let G__22 = true;
|
|
2035
|
+
node3 = G__17;
|
|
2036
|
+
ropts4 = G__18;
|
|
2037
|
+
inherited5 = G__19;
|
|
2038
|
+
toks6 = G__20;
|
|
2039
|
+
level7 = G__21;
|
|
2040
|
+
eoo_QMARK_8 = G__22;
|
|
2041
|
+
continue;
|
|
2042
|
+
} else {
|
|
2043
|
+
if (squint_core.truth_((!eoo_QMARK_8 && squint_core.get_in(node3, ["cmd", head12])))) {
|
|
2044
|
+
const inherited23 = squint_core.merge(inherited5, inherited_entries(squint_core.get(node3, "spec"), inherit_opt1));
|
|
2045
|
+
const child24 = squint_core.get_in(node3, ["cmd", head12]);
|
|
2046
|
+
let G__25 = child24;
|
|
2047
|
+
let G__26 = resolve_node2(inherited23, child24);
|
|
2048
|
+
let G__27 = inherited23;
|
|
2049
|
+
let G__28 = squint_core.next(toks6);
|
|
2050
|
+
let G__29 = [];
|
|
2051
|
+
let G__30 = false;
|
|
2052
|
+
node3 = G__25;
|
|
2053
|
+
ropts4 = G__26;
|
|
2054
|
+
inherited5 = G__27;
|
|
2055
|
+
toks6 = G__28;
|
|
2056
|
+
level7 = G__29;
|
|
2057
|
+
eoo_QMARK_8 = G__30;
|
|
2058
|
+
continue;
|
|
2059
|
+
} else {
|
|
2060
|
+
if (squint_core.truth_((!eoo_QMARK_8 && gnu_option_QMARK_(head12)))) {
|
|
2061
|
+
const n31 = ((squint_core.truth_(bool_opt_QMARK_(head12, opts14, known16))) ? (1) : (2));
|
|
2062
|
+
let G__32 = node3;
|
|
2063
|
+
let G__33 = ropts4;
|
|
2064
|
+
let G__34 = inherited5;
|
|
2065
|
+
let G__35 = squint_core.drop(n31, toks6);
|
|
2066
|
+
let G__36 = squint_core.into(level7, squint_core.take(n31, toks6));
|
|
2067
|
+
let G__37 = eoo_QMARK_8;
|
|
2068
|
+
node3 = G__32;
|
|
2069
|
+
ropts4 = G__33;
|
|
2070
|
+
inherited5 = G__34;
|
|
2071
|
+
toks6 = G__35;
|
|
2072
|
+
level7 = G__36;
|
|
2073
|
+
eoo_QMARK_8 = G__37;
|
|
2074
|
+
continue;
|
|
2075
|
+
} else {
|
|
2076
|
+
if ("else") {
|
|
2077
|
+
let G__38 = node3;
|
|
2078
|
+
let G__39 = ropts4;
|
|
2079
|
+
let G__40 = inherited5;
|
|
2080
|
+
let G__41 = squint_core.next(toks6);
|
|
2081
|
+
let G__42 = squint_core.conj(level7, head12);
|
|
2082
|
+
let G__43 = eoo_QMARK_8;
|
|
2083
|
+
node3 = G__38;
|
|
2084
|
+
ropts4 = G__39;
|
|
2085
|
+
inherited5 = G__40;
|
|
2086
|
+
toks6 = G__41;
|
|
2087
|
+
level7 = G__42;
|
|
2088
|
+
eoo_QMARK_8 = G__43;
|
|
2089
|
+
continue;
|
|
2090
|
+
} else {
|
|
2091
|
+
return null}}}}};
|
|
2092
|
+
;break;
|
|
2093
|
+
}
|
|
2094
|
+
;
|
|
2095
|
+
|
|
2096
|
+
};
|
|
2097
|
+
var split_eq = function (token) {
|
|
2098
|
+
if (squint_core.truth_((() => {
|
|
2099
|
+
const and__23691__auto__1 = str.starts_with_QMARK_(token, "--");
|
|
2100
|
+
if (squint_core.truth_(and__23691__auto__1)) {
|
|
2101
|
+
return str.includes_QMARK_(token, "=")} else {
|
|
2102
|
+
return and__23691__auto__1};
|
|
2103
|
+
|
|
2104
|
+
})())) {
|
|
2105
|
+
return str.split(token, /=/, 2)} else {
|
|
2106
|
+
return [token]};
|
|
2107
|
+
|
|
2108
|
+
};
|
|
2109
|
+
var complete_tree_STAR_ = (() => {
|
|
2110
|
+
const f68 = (function (...args69) {
|
|
2111
|
+
const G__701 = args69.length;
|
|
2112
|
+
switch (G__701) {case 2:
|
|
2113
|
+
return f68.cljs$core$IFn$_invoke$arity$2(args69[0], args69[1]);
|
|
2114
|
+
|
|
2115
|
+
break;
|
|
2116
|
+
case 3:
|
|
2117
|
+
return f68.cljs$core$IFn$_invoke$arity$3(args69[0], args69[1], args69[2]);
|
|
2118
|
+
|
|
2119
|
+
break;
|
|
2120
|
+
default:
|
|
2121
|
+
throw (new Error(`${"Invalid arity: "}${args69.length??''}`))};
|
|
2122
|
+
|
|
2123
|
+
});
|
|
2124
|
+
f68.cljs$core$IFn$_invoke$arity$2 = (function (cmd_tree, args) {
|
|
2125
|
+
return complete_tree_STAR_(cmd_tree, args, null);
|
|
2126
|
+
|
|
2127
|
+
});
|
|
2128
|
+
f68.cljs$core$IFn$_invoke$arity$3 = (function (cmd_tree, args, global_opts) {
|
|
2129
|
+
const done12 = squint_core.vec(squint_core.mapcat(split_eq, squint_core.butlast(args)));
|
|
2130
|
+
const raw_last13 = (() => {
|
|
2131
|
+
const or__23664__auto__14 = squint_core.last(args);
|
|
2132
|
+
if (squint_core.truth_(or__23664__auto__14)) {
|
|
2133
|
+
return or__23664__auto__14} else {
|
|
2134
|
+
return ""};
|
|
2135
|
+
|
|
2136
|
+
})();
|
|
2137
|
+
const vec__315 = (() => {
|
|
2138
|
+
const s16 = split_eq(raw_last13);
|
|
2139
|
+
if (squint_core.truth_(squint_core.second(s16))) {
|
|
2140
|
+
return s16;
|
|
2141
|
+
};
|
|
2142
|
+
|
|
2143
|
+
})();
|
|
2144
|
+
const eq_opt17 = squint_core.nth(vec__315, 0, null);
|
|
2145
|
+
const eq_val18 = squint_core.nth(vec__315, 1, null);
|
|
2146
|
+
const vec__619 = descend(cmd_tree, global_opts, done12);
|
|
2147
|
+
const vec__920 = squint_core.nth(vec__619, 0, null);
|
|
2148
|
+
const opts21 = squint_core.nth(vec__920, 0, null);
|
|
2149
|
+
const aliases22 = squint_core.nth(vec__920, 1, null);
|
|
2150
|
+
const known23 = squint_core.nth(vec__920, 2, null);
|
|
2151
|
+
const node24 = squint_core.nth(vec__619, 1, null);
|
|
2152
|
+
const level25 = squint_core.nth(vec__619, 2, null);
|
|
2153
|
+
const eoo_QMARK_26 = squint_core.nth(vec__619, 3, null);
|
|
2154
|
+
const spec27 = squint_core.get(opts21, "spec");
|
|
2155
|
+
const previous28 = squint_core.peek(done12);
|
|
2156
|
+
if (squint_core.truth_(eoo_QMARK_26)) {
|
|
2157
|
+
const map__2930 = safe_parse(level25, opts21);
|
|
2158
|
+
const parsed31 = squint_core.get(map__2930, "opts");
|
|
2159
|
+
const pos_args32 = squint_core.get(map__2930, "args");
|
|
2160
|
+
return positional_candidates(node24, spec27, pos_args32, parsed31, raw_last13);
|
|
2161
|
+
} else {
|
|
2162
|
+
if (squint_core.truth_(eq_opt17)) {
|
|
2163
|
+
const map__3334 = safe_parse(level25, opts21);
|
|
2164
|
+
const parsed35 = squint_core.get(map__3334, "opts");
|
|
2165
|
+
return squint_core.map((function (_PERCENT_1) {
|
|
2166
|
+
return squint_core.update(_PERCENT_1, "value", (function (v) {
|
|
2167
|
+
return `${eq_opt17??''}${"="}${v??''}`;
|
|
2168
|
+
|
|
2169
|
+
}));
|
|
2170
|
+
|
|
2171
|
+
}), squint_core.remove("file-completion", value_candidates(spec27, opts21, eq_opt17, eq_val18, parsed35)));
|
|
2172
|
+
} else {
|
|
2173
|
+
if (squint_core.truth_((() => {
|
|
2174
|
+
const and__23691__auto__36 = gnu_option_QMARK_(previous28);
|
|
2175
|
+
if (squint_core.truth_(and__23691__auto__36)) {
|
|
2176
|
+
return squint_core.not(bool_opt_QMARK_(previous28, opts21, known23))} else {
|
|
2177
|
+
return and__23691__auto__36};
|
|
2178
|
+
|
|
2179
|
+
})())) {
|
|
2180
|
+
const map__3738 = safe_parse(squint_core.vec(squint_core.butlast(level25)), opts21);
|
|
2181
|
+
const parsed39 = squint_core.get(map__3738, "opts");
|
|
2182
|
+
return value_candidates(spec27, opts21, previous28, raw_last13, parsed39);
|
|
2183
|
+
} else {
|
|
2184
|
+
if ("else") {
|
|
2185
|
+
const map__4041 = safe_parse(level25, opts21);
|
|
2186
|
+
const parsed42 = squint_core.get(map__4041, "opts");
|
|
2187
|
+
const pos_args43 = squint_core.get(map__4041, "args");
|
|
2188
|
+
return squint_core.concat(((squint_core.truth_(gnu_option_QMARK_(raw_last13))) ? (null) : (command_candidates(node24, raw_last13))), option_candidates(spec27, opts21, aliases22, known23, parsed42, raw_last13), ((squint_core.truth_(gnu_option_QMARK_(raw_last13))) ? (null) : (positional_candidates(node24, spec27, pos_args43, parsed42, raw_last13))));
|
|
2189
|
+
} else {
|
|
2190
|
+
return null}}}};
|
|
2191
|
+
|
|
2192
|
+
});
|
|
2193
|
+
f68.cljs$lang$maxFixedArity = 3;
|
|
2194
|
+
return f68;
|
|
2195
|
+
|
|
2196
|
+
})();
|
|
2197
|
+
var completion_shell_snippet = function (shell, names) {
|
|
2198
|
+
const program_name1 = squint_core.first(names);
|
|
2199
|
+
const fn2 = `_babashka_cli_complete_${str.replace(program_name1, /[^a-zA-Z0-9_]+/, "_")??''}`;
|
|
2200
|
+
const names_sp3 = str.join(" ", names);
|
|
2201
|
+
const names_csv4 = str.join(",", names);
|
|
2202
|
+
const names_nu5 = `${"["}${str.join(" ", squint_core.map((function (_PERCENT_1) {
|
|
2203
|
+
return `${"\""}${_PERCENT_1??''}${"\""}`;
|
|
2204
|
+
|
|
2205
|
+
}), names))??''}${"]"}`;
|
|
2206
|
+
const G__716 = shell;
|
|
2207
|
+
switch (G__716) {case "bash":
|
|
2208
|
+
return `${fn2}${"()\n{\n local cur words cword\n # -n =: keeps --opt=val and ns:val as single words (bash splits on = and :\n # via COMP_WORDBREAKS); the no-bash-completion fallback below cannot, so a : in\n # a value is only fully handled when bash-completion is installed\n if declare -F _init_completion >/dev/null 2>&1; then\n _init_completion -n =: || return\n else\n words=(\"${COMP_WORDS[@]}\"); cword=$COMP_CWORD; cur=\"${COMP_WORDS[COMP_CWORD]}\"\n fi\n # keep our candidate order. Only on the real compopt builtin (bash 4.4+): on\n # bash 3.2 with bash-completion, compopt is a shim that forwards to `complete`,\n # which rejects -o nosort. The probe is cached: its answer never changes\n if [[ -z ${_babashka_cli_compopt_t+x} ]]; then _babashka_cli_compopt_t=$(type -t compopt); fi\n [[ $_babashka_cli_compopt_t == builtin ]] && compopt -o nosort 2>/dev/null\n local out\n out=$(\"${words[0]}\" org.babashka.cli/completions complete --shell bash -- \"${words[@]:1:cword}\" 2>/dev/null)\n # candidates come back already prefix-filtered; insert them verbatim.\n # read -r keeps them out of word splitting and pathname expansion (an\n # unquoted loop would glob a '*.txt' candidate against the cwd), printf %q\n # escapes spaces/quotes for insertion\n local line v\n while IFS= read -r line; do\n [[ -n $line ]] || continue\n if [[ $line == org.babashka.cli/file-completion ]]; then\n compopt -o filenames 2>/dev/null\n while IFS= read -r v; do\n [[ -n $v ]] && COMPREPLY+=( \"$v\" )\n done < <(compgen -f -- \"$cur\")\n else\n v=${line%%$'\\t'*}\n printf -v v '%q' \"$v\"\n COMPREPLY+=( \"$v\" )\n fi\n done <<< \"$out\"\n # bash re-inserts from the last COMP_WORDBREAKS char (e.g. : or =); strip that\n # prefix from each candidate so colon/equals values complete without duplication\n local wb pre i\n for wb in : = ; do\n if [[ \"$cur\" == *\"$wb\"* && \"$COMP_WORDBREAKS\" == *\"$wb\"* ]]; then\n pre=\"${cur%\"${cur##*$wb}\"}\"\n for ((i=0; i<${#COMPREPLY[@]}; i++)); do COMPREPLY[$i]=\"${COMPREPLY[$i]#\"$pre\"}\"; done\n fi\n done\n}\ncomplete -F "}${fn2}${" "}${names_sp3??''}${"\n"}`;
|
|
2209
|
+
|
|
2210
|
+
break;
|
|
2211
|
+
case "zsh":
|
|
2212
|
+
return `${"#compdef "}${names_sp3??''}${"\n"}${fn2}${"() {\n local -a lines described\n lines=(\"${(@f)$(\"${words[1]}\" org.babashka.cli/completions complete --shell zsh -- \"${(@)words[2,CURRENT]}\" 2>/dev/null)}\")\n local do_files= l v d\n for l in $lines; do\n if [[ $l == org.babashka.cli/file-completion ]]; then do_files=1; continue; fi\n v=\"${l%%$'\\t'*}\"; d=\n [[ $l == *$'\\t'* ]] && d=\"${l#*$'\\t'}\"\n # _describe eats backslashes and splits on ':', so escape both\n v=\"${v//\\\\/\\\\\\\\}\"; d=\"${d//\\\\/\\\\\\\\}\"\n v=\"${v//:/\\\\:}\"; d=\"${d//:/\\\\:}\"\n described+=(\"$v${d:+:$d}\")\n done\n local ret=1\n # claim success whenever we produced candidates: _describe's own exit status\n # is not reliably 0 under a user matcher-list / multi-completer setup, and a\n # non-zero return makes zsh retry other completers (_match, _approximate, ...)\n # and re-list everything with detached descriptions\n (( $#described )) && { _describe -t values completion described; ret=0; }\n [[ -n $do_files ]] && { _files; ret=0; }\n return $ret\n}\n# register the bare name(s); zsh's _normal completes ./name and /abs/name via the basename\ncompdef "}${fn2}${" "}${names_sp3??''}${"\n"}`;
|
|
2213
|
+
|
|
2214
|
+
break;
|
|
2215
|
+
case "fish":
|
|
2216
|
+
return `${"function "}${fn2}${"\n set -l toks (commandline --tokenize --cut-at-cursor)\n set -l prog $toks[1]\n set -e toks[1]\n set -l cur (commandline --current-token)\n for line in ($prog org.babashka.cli/completions complete --shell fish -- $toks \"$cur\" 2>/dev/null)\n if test \"$line\" = org.babashka.cli/file-completion\n __fish_complete_path \"$cur\"\n else\n # printf, not echo: echo eats a bare -n/-e candidate as its own flag\n printf '%s\\n' $line\n end\n end\nend\n"}${str.join("\n", squint_core.map((function (_PERCENT_1) {
|
|
2217
|
+
return `${"complete --command "}${_PERCENT_1??''}${" --no-files --arguments \"("}${fn2}${")\""}`;
|
|
2218
|
+
|
|
2219
|
+
}), names))??''}${"\n"}`;
|
|
2220
|
+
|
|
2221
|
+
break;
|
|
2222
|
+
case "powershell":
|
|
2223
|
+
return `${"Register-ArgumentCompleter -Native -CommandName "}${names_csv4??''}${" -ScriptBlock {\n param($wordToComplete, $commandAst, $cursorPosition)\n $exe = $commandAst.CommandElements[0].Value\n $toks = @()\n for ($i = 1; $i -lt $commandAst.CommandElements.Count; $i++) {\n $el = $commandAst.CommandElements[$i]\n if ($el.Extent.StartOffset -ge $cursorPosition) { break }\n $toks += $el.Extent.Text\n }\n # a fresh word is signaled via --fresh, not a trailing '' token: PowerShell 5.1\n # and pwsh with legacy native argument passing drop empty-string arguments\n $fresh = if ($wordToComplete) { 'false' } else { 'true' }\n $lines = @(& $exe org.babashka.cli/completions complete --shell powershell --fresh $fresh -- $toks 2>$null)\n $lines | Where-Object { $_ -ne 'org.babashka.cli/file-completion' } | ForEach-Object {\n $parts = $_ -split \"`t\", 2\n $tip = if ($parts.Length -gt 1) { $parts[1] } else { $parts[0] }\n $text = $parts[0]\n if ($text -match '\\s') { $text = \"'\" + ($text -replace \"'\", \"''\") + \"'\" }\n [System.Management.Automation.CompletionResult]::new($text, $parts[0], 'ParameterValue', $tip)\n }\n if ($lines -contains 'org.babashka.cli/file-completion') {\n [System.Management.Automation.CompletionCompleters]::CompleteFilename($wordToComplete)\n }\n}\n"}`;
|
|
2224
|
+
|
|
2225
|
+
break;
|
|
2226
|
+
case "nushell":
|
|
2227
|
+
return `${"# "}${program_name1??''}${" tab completion for nushell. Nushell completes external\n# commands through one global external completer, so this chains any previously\n# configured completer: several CLIs can install side by side\nlet "}${fn2}${"_prev = $env.config.completions?.external?.completer?\n$env.config.completions.external.enable = true\n$env.config.completions.external.completer = {|spans|\n if ($spans | first | path basename) in "}${names_nu5}${" {\n let res = (do { ^($spans | first) org.babashka.cli/completions complete --shell nushell -- ...($spans | skip 1) } | complete)\n let lines = (if $res.exit_code == 0 { $res.stdout | lines } else { [] })\n if \"org.babashka.cli/file-completion\" in $lines {\n null # defer to nushell's own file completion\n } else {\n $lines | each {|l|\n let parts = ($l | split row -n 2 \"\\t\")\n if ($parts | length) == 2 {\n {value: $parts.0, description: $parts.1}\n } else {\n {value: $parts.0}\n }\n }\n }\n } else if $"}${fn2}${"_prev != null {\n do $"}${fn2}${"_prev $spans\n } else {\n null\n }\n}\n"}`;
|
|
2228
|
+
|
|
2229
|
+
break;
|
|
2230
|
+
default:
|
|
2231
|
+
throw (new Error(`${"No matching clause: "}${G__716??''}`))};
|
|
2232
|
+
|
|
2233
|
+
};
|
|
2234
|
+
var print_completions = function (candidates) {
|
|
2235
|
+
for (let G__1 of squint_core.iterable(candidates)) {
|
|
2236
|
+
const map__23 = G__1;
|
|
2237
|
+
const value4 = squint_core.get(map__23, "value");
|
|
2238
|
+
const description5 = squint_core.get(map__23, "description");
|
|
2239
|
+
const value6 = str.replace(value4, /[\t\n\r]/, " ");
|
|
2240
|
+
const desc7 = ((squint_core.truth_(str.blank_QMARK_(description5))) ? (null) : (str.replace(squint_core.first(str.split_lines(description5)), "\t", " ")));
|
|
2241
|
+
squint_core.println(((squint_core.truth_(desc7)) ? (`${value6??''}${"\t"}${desc7??''}`) : (value6)))
|
|
2242
|
+
}
|
|
2243
|
+
return null;
|
|
2244
|
+
|
|
2245
|
+
};
|
|
2246
|
+
var eprintln = function (s) {
|
|
2247
|
+
const binding__721 = squint_core._STAR_print_fn_STAR_.val;
|
|
2248
|
+
squint_core._STAR_print_fn_STAR_.val = squint_core._STAR_print_err_fn_STAR_.val;
|
|
2249
|
+
return (() => {
|
|
2250
|
+
try{
|
|
2251
|
+
return squint_core.println(s);
|
|
2252
|
+
}
|
|
2253
|
+
finally{
|
|
2254
|
+
squint_core._STAR_print_fn_STAR_.val = binding__721}
|
|
2255
|
+
|
|
2256
|
+
})();
|
|
2257
|
+
|
|
2258
|
+
};
|
|
2259
|
+
var has_parse_opts_QMARK_ = function (m) {
|
|
2260
|
+
return squint_core.some((new Set (["spec", "coerce", "require", "restrict", "validate", "args->opts", "exec-args"])), squint_core.keys(m));
|
|
2261
|
+
|
|
2262
|
+
};
|
|
2263
|
+
var is_option_QMARK_ = function (s) {
|
|
2264
|
+
const and__23691__auto__1 = s;
|
|
2265
|
+
if (squint_core.truth_(and__23691__auto__1)) {
|
|
2266
|
+
const or__23664__auto__2 = str.starts_with_QMARK_(s, "-");
|
|
2267
|
+
if (squint_core.truth_(or__23664__auto__2)) {
|
|
2268
|
+
return or__23664__auto__2} else {
|
|
2269
|
+
return str.starts_with_QMARK_(s, ":")};
|
|
2270
|
+
} else {
|
|
2271
|
+
return and__23691__auto__1};
|
|
2272
|
+
|
|
2273
|
+
};
|
|
2274
|
+
var command_help_context = function (tree, cmds, prog, inherit) {
|
|
2275
|
+
const node_at1 = (function (path) {
|
|
2276
|
+
return squint_core.get_in(tree, squint_core.interleave(squint_core.repeat("cmd"), path));
|
|
2277
|
+
|
|
2278
|
+
});
|
|
2279
|
+
const prog_at2 = (function (path) {
|
|
2280
|
+
return str.join(" ", squint_core.cons(prog, path));
|
|
2281
|
+
|
|
2282
|
+
});
|
|
2283
|
+
const here3 = squint_core.set(squint_core.keys(__GT_spec_map(squint_core.get(node_at1(cmds), "spec"))));
|
|
2284
|
+
const ancestors4 = squint_core.lazy((function* () {
|
|
2285
|
+
for (let G__5 of squint_core.iterable(squint_core.range(squint_core.count(cmds)))) {
|
|
2286
|
+
const i6 = G__5;
|
|
2287
|
+
const pre7 = squint_core.subvec(cmds, 0, i6);
|
|
2288
|
+
const spec8 = __GT_spec_map(squint_core.get(node_at1(pre7), "spec"));
|
|
2289
|
+
const inh9 = inherited_entries(spec8, inherit);
|
|
2290
|
+
yield ({"pre": pre7, "inh": inh9, "own": squint_core.apply(squint_core.dissoc, spec8, squint_core.keys(inh9))});
|
|
2291
|
+
}
|
|
2292
|
+
return null;
|
|
2293
|
+
|
|
2294
|
+
}));
|
|
2295
|
+
const inherited10 = squint_core.reduce(squint_core.merge, ({}), squint_core.map("inh", ancestors4));
|
|
2296
|
+
const parents11 = squint_core.lazy((function* () {
|
|
2297
|
+
for (let G__12 of squint_core.iterable(ancestors4)) {
|
|
2298
|
+
const map__1314 = G__12;
|
|
2299
|
+
const pre15 = squint_core.get(map__1314, "pre");
|
|
2300
|
+
const own16 = squint_core.get(map__1314, "own");
|
|
2301
|
+
const own17 = squint_core.apply(squint_core.dissoc, own16, here3);
|
|
2302
|
+
if (squint_core.truth_(squint_core.seq(own17))) {
|
|
2303
|
+
yield ({"prog": prog_at2(pre15), "name": ((squint_core.truth_(squint_core.seq(pre15))) ? (squint_core.peek(pre15)) : ("global"))});}
|
|
2304
|
+
}
|
|
2305
|
+
return null;
|
|
2306
|
+
|
|
2307
|
+
}));
|
|
2308
|
+
return ({"node": node_at1(cmds), "prog": prog_at2(cmds), "inherited": inherited10, "parents": squint_core.vec(parents11)});
|
|
2309
|
+
|
|
2310
|
+
};
|
|
2311
|
+
var format_command_help = function (p__73) {
|
|
2312
|
+
const map__12 = p__73;
|
|
2313
|
+
const table3 = squint_core.get(map__12, "table");
|
|
2314
|
+
const cmds4 = squint_core.get(map__12, "cmds", []);
|
|
2315
|
+
const prog5 = squint_core.get(map__12, "prog");
|
|
2316
|
+
const inherit6 = squint_core.get(map__12, "inherit");
|
|
2317
|
+
const tree7 = table__GT_tree(table3);
|
|
2318
|
+
const ctx8 = command_help_context(tree7, squint_core.vec(cmds4), prog5, inherit6);
|
|
2319
|
+
return render_help(squint_core.get(ctx8, "node"), ctx8);
|
|
2320
|
+
|
|
2321
|
+
};
|
|
2322
|
+
var _STAR_exit_fn_STAR_ = ({val: function (p__74) {
|
|
2323
|
+
const map__12 = p__74;
|
|
2324
|
+
const exit3 = squint_core.get(map__12, "exit");
|
|
2325
|
+
if (squint_core.truth_(((typeof process !== 'undefined') && squint_core.fn_QMARK_(process.exit)))) {
|
|
2326
|
+
return process.exit(exit3)} else {
|
|
2327
|
+
throw squint_core.ex_info("exit", ({"exit": exit3}))};
|
|
2328
|
+
|
|
2329
|
+
}});
|
|
2330
|
+
var print_command_help = function (p__75) {
|
|
2331
|
+
const map__12 = p__75;
|
|
2332
|
+
const tree3 = squint_core.get(map__12, "tree");
|
|
2333
|
+
const dispatch4 = squint_core.get(map__12, "dispatch");
|
|
2334
|
+
const prog5 = squint_core.get(map__12, "prog");
|
|
2335
|
+
const inherit6 = squint_core.get(map__12, "inherit");
|
|
2336
|
+
return squint_core.println(format_command_help(({"table": tree3, "cmds": (() => {
|
|
2337
|
+
const or__23664__auto__7 = dispatch4;
|
|
2338
|
+
if (squint_core.truth_(or__23664__auto__7)) {
|
|
2339
|
+
return or__23664__auto__7} else {
|
|
2340
|
+
return []};
|
|
2341
|
+
|
|
2342
|
+
})(), "prog": prog5, "inherit": inherit6})));
|
|
2343
|
+
|
|
2344
|
+
};
|
|
2345
|
+
var format_command_error = function (p__76) {
|
|
2346
|
+
const map__12 = p__76;
|
|
2347
|
+
const cause3 = squint_core.get(map__12, "cause");
|
|
2348
|
+
const dispatch4 = squint_core.get(map__12, "dispatch");
|
|
2349
|
+
const wrong_input5 = squint_core.get(map__12, "wrong-input");
|
|
2350
|
+
const msg6 = squint_core.get(map__12, "msg");
|
|
2351
|
+
const prog7 = squint_core.get(map__12, "prog");
|
|
2352
|
+
const inherit8 = squint_core.get(map__12, "inherit");
|
|
2353
|
+
const tree9 = squint_core.get(map__12, "tree");
|
|
2354
|
+
const tree10 = table__GT_tree(tree9);
|
|
2355
|
+
const path11 = (() => {
|
|
2356
|
+
const or__23664__auto__12 = dispatch4;
|
|
2357
|
+
if (squint_core.truth_(or__23664__auto__12)) {
|
|
2358
|
+
return or__23664__auto__12} else {
|
|
2359
|
+
return []};
|
|
2360
|
+
|
|
2361
|
+
})();
|
|
2362
|
+
const ctx_at13 = (function (p) {
|
|
2363
|
+
return command_help_context(tree10, squint_core.vec(p), prog7, inherit8);
|
|
2364
|
+
|
|
2365
|
+
});
|
|
2366
|
+
const hint14 = `${"Run \""}${str.join(" ", squint_core.cons(prog7, path11))??''}${" --help\" for more information."}`;
|
|
2367
|
+
const usage15 = (function (p) {
|
|
2368
|
+
const map__1617 = ctx_at13(p);
|
|
2369
|
+
const node18 = squint_core.get(map__1617, "node");
|
|
2370
|
+
const prog19 = squint_core.get(map__1617, "prog");
|
|
2371
|
+
const inherited20 = squint_core.get(map__1617, "inherited");
|
|
2372
|
+
return help_usage_line(prog19, node18, (() => {
|
|
2373
|
+
const or__23664__auto__21 = squint_core.seq(squint_core.get(node18, "spec"));
|
|
2374
|
+
if (squint_core.truth_(or__23664__auto__21)) {
|
|
2375
|
+
return or__23664__auto__21} else {
|
|
2376
|
+
return squint_core.seq(inherited20)};
|
|
2377
|
+
|
|
2378
|
+
})());
|
|
2379
|
+
|
|
2380
|
+
});
|
|
2381
|
+
const command_error22 = (function (message) {
|
|
2382
|
+
const cmds23 = help_commands_table(squint_core.get(ctx_at13(path11), "node"));
|
|
2383
|
+
return str.join("\n", squint_core.concat([message, ""], ((squint_core.truth_(squint_core.seq(cmds23))) ? ([`${"Commands:\n"}${format_table(({"rows": cmds23, "indent": 2}))??''}`, ""]) : (null)), [hint14]));
|
|
2384
|
+
|
|
2385
|
+
});
|
|
2386
|
+
if (("no-match" === cause3)) {
|
|
2387
|
+
return command_error22(`${"Unknown command: "}${wrong_input5??''}`)} else {
|
|
2388
|
+
if (("input-exhausted" === cause3)) {
|
|
2389
|
+
return command_error22("No command given.")} else {
|
|
2390
|
+
if ("else") {
|
|
2391
|
+
return str.join("\n", [`${"Error: "}${msg6??''}`, "", usage15(path11), "", hint14])} else {
|
|
2392
|
+
return null}}};
|
|
2393
|
+
|
|
2394
|
+
};
|
|
2395
|
+
var print_command_error = function (data) {
|
|
2396
|
+
return eprintln(format_command_error(data));
|
|
2397
|
+
|
|
2398
|
+
};
|
|
2399
|
+
var thread_dispatch_context = function (data, p__77) {
|
|
2400
|
+
const map__12 = p__77;
|
|
2401
|
+
const prog3 = squint_core.get(map__12, "prog");
|
|
2402
|
+
const inherit4 = squint_core.get(map__12, "inherit");
|
|
2403
|
+
const G__785 = data;
|
|
2404
|
+
const G__786 = ((squint_core.truth_(prog3)) ? (squint_core.assoc(G__785, "prog", prog3)) : (G__785));
|
|
2405
|
+
if (squint_core.truth_(inherit4)) {
|
|
2406
|
+
return squint_core.assoc(G__786, "inherit", inherit4)} else {
|
|
2407
|
+
return G__786};
|
|
2408
|
+
|
|
2409
|
+
};
|
|
2410
|
+
var visible_command_names = function (cmd_info) {
|
|
2411
|
+
return squint_core.mapv(squint_core.first, cmd_children(cmd_info));
|
|
2412
|
+
|
|
2413
|
+
};
|
|
2414
|
+
var dispatch_tree_SINGLEQUOTE_ = (() => {
|
|
2415
|
+
const f79 = (function (...args80) {
|
|
2416
|
+
const G__811 = args80.length;
|
|
2417
|
+
switch (G__811) {case 2:
|
|
2418
|
+
return f79.cljs$core$IFn$_invoke$arity$2(args80[0], args80[1]);
|
|
2419
|
+
|
|
2420
|
+
break;
|
|
2421
|
+
case 3:
|
|
2422
|
+
return f79.cljs$core$IFn$_invoke$arity$3(args80[0], args80[1], args80[2]);
|
|
2423
|
+
|
|
2424
|
+
break;
|
|
2425
|
+
default:
|
|
2426
|
+
throw (new Error(`${"Invalid arity: "}${args80.length??''}`))};
|
|
2427
|
+
|
|
2428
|
+
});
|
|
2429
|
+
f79.cljs$core$IFn$_invoke$arity$2 = (function (tree, args) {
|
|
2430
|
+
return dispatch_tree_SINGLEQUOTE_(tree, args, null);
|
|
2431
|
+
|
|
2432
|
+
});
|
|
2433
|
+
f79.cljs$core$IFn$_invoke$arity$3 = (function (tree, args, opts) {
|
|
2434
|
+
let cmds3 = [];
|
|
2435
|
+
let all_opts4 = ({});
|
|
2436
|
+
let args5 = args;
|
|
2437
|
+
let cmd_info6 = tree;
|
|
2438
|
+
let inherited7 = ({});
|
|
2439
|
+
while(true){
|
|
2440
|
+
const kwm12 = cmd_info6;
|
|
2441
|
+
const inherit_opt13 = squint_core.get(opts, "inherit");
|
|
2442
|
+
const prog14 = squint_core.get(opts, "prog");
|
|
2443
|
+
const help_QMARK_15 = squint_core.get(opts, "babashka.cli/help");
|
|
2444
|
+
const should_parse_args_QMARK_16 = (() => {
|
|
2445
|
+
const or__23664__auto__17 = has_parse_opts_QMARK_(kwm12);
|
|
2446
|
+
if (squint_core.truth_(or__23664__auto__17)) {
|
|
2447
|
+
return or__23664__auto__17} else {
|
|
2448
|
+
const or__23664__auto__18 = squint_core.seq(inherited7);
|
|
2449
|
+
if (squint_core.truth_(or__23664__auto__18)) {
|
|
2450
|
+
return or__23664__auto__18} else {
|
|
2451
|
+
return is_option_QMARK_(squint_core.first(args5))};
|
|
2452
|
+
};
|
|
2453
|
+
|
|
2454
|
+
})();
|
|
2455
|
+
const parse_opts19 = deep_merge(opts, kwm12);
|
|
2456
|
+
const parse_opts20 = (() => {
|
|
2457
|
+
const G__8221 = parse_opts19;
|
|
2458
|
+
if (squint_core.truth_(squint_core.seq(inherited7))) {
|
|
2459
|
+
return squint_core.assoc(G__8221, "spec", deep_merge(deep_merge(__GT_spec_map(squint_core.get(opts, "spec")), inherited7), __GT_spec_map(squint_core.get(kwm12, "spec"))))} else {
|
|
2460
|
+
return G__8221};
|
|
2461
|
+
|
|
2462
|
+
})();
|
|
2463
|
+
const user_error_fn22 = squint_core.get(parse_opts20, "error-fn");
|
|
2464
|
+
const error_stash23 = squint_core.get(opts, "babashka.cli/error-stash");
|
|
2465
|
+
const parse_opts24 = squint_core.assoc(parse_opts20, "error-fn", (function (data) {
|
|
2466
|
+
const data25 = thread_dispatch_context(squint_core.assoc(data, "dispatch", cmds3, "tree", tree), ({"prog": prog14, "inherit": inherit_opt13}));
|
|
2467
|
+
const fire26 = (function () {
|
|
2468
|
+
if (squint_core.truth_(user_error_fn22)) {
|
|
2469
|
+
return user_error_fn22(data25)} else {
|
|
2470
|
+
throw squint_core.ex_info(squint_core.get(data25, "msg"), data25)};
|
|
2471
|
+
|
|
2472
|
+
});
|
|
2473
|
+
if (squint_core.truth_(error_stash23)) {
|
|
2474
|
+
return squint_core.swap_BANG_(error_stash23, squint_core.conj, fire26)} else {
|
|
2475
|
+
return fire26()};
|
|
2476
|
+
|
|
2477
|
+
}));
|
|
2478
|
+
const map__827 = ((squint_core.truth_(should_parse_args_QMARK_16)) ? (parse_args(args5, squint_core.assoc(parse_opts24, "babashka.cli/dispatch-tree", true, "babashka.cli/dispatch-inherited", all_opts4, "babashka.cli/dispatch-tree-ignored-args", squint_core.set(squint_core.keys(squint_core.get(cmd_info6, "cmd")))))) : (({"args": args5, "opts": ({})})));
|
|
2479
|
+
const args28 = squint_core.get(map__827, "args");
|
|
2480
|
+
const opts29 = squint_core.get(map__827, "opts");
|
|
2481
|
+
const vec__930 = args28;
|
|
2482
|
+
const seq__1031 = squint_core.seq(vec__930);
|
|
2483
|
+
const first__1132 = squint_core.first(seq__1031);
|
|
2484
|
+
const seq__1033 = squint_core.next(seq__1031);
|
|
2485
|
+
const arg34 = first__1132;
|
|
2486
|
+
const rest35 = seq__1033;
|
|
2487
|
+
const all_opts36 = squint_core.update(squint_core.merge(all_opts4, opts29), "babashka.cli/opts-by-cmds", squint_core.fnil(squint_core.conj, []), ({"cmds": cmds3, "opts": opts29}));
|
|
2488
|
+
if (squint_core.truth_((() => {
|
|
2489
|
+
const and__23691__auto__37 = help_QMARK_15;
|
|
2490
|
+
if (squint_core.truth_(and__23691__auto__37)) {
|
|
2491
|
+
const or__23664__auto__38 = squint_core.get(opts29, "help");
|
|
2492
|
+
if (squint_core.truth_(or__23664__auto__38)) {
|
|
2493
|
+
return or__23664__auto__38} else {
|
|
2494
|
+
return squint_core.get(opts29, "h")};
|
|
2495
|
+
} else {
|
|
2496
|
+
return and__23691__auto__37};
|
|
2497
|
+
|
|
2498
|
+
})())) {
|
|
2499
|
+
return ({"error": "help", "dispatch": cmds3, "opts": squint_core.dissoc(all_opts36, "babashka.cli/opts-by-cmds")})} else {
|
|
2500
|
+
const temp__23189__auto__39 = squint_core.get(squint_core.get(cmd_info6, "cmd"), arg34);
|
|
2501
|
+
if (squint_core.truth_(temp__23189__auto__39)) {
|
|
2502
|
+
const subcmd_info40 = temp__23189__auto__39;
|
|
2503
|
+
let G__41 = squint_core.conj(cmds3, arg34);
|
|
2504
|
+
let G__42 = all_opts36;
|
|
2505
|
+
let G__43 = rest35;
|
|
2506
|
+
let G__44 = subcmd_info40;
|
|
2507
|
+
let G__45 = squint_core.merge(inherited7, inherited_entries(squint_core.get(kwm12, "spec"), inherit_opt13));
|
|
2508
|
+
cmds3 = G__41;
|
|
2509
|
+
all_opts4 = G__42;
|
|
2510
|
+
args5 = G__43;
|
|
2511
|
+
cmd_info6 = G__44;
|
|
2512
|
+
inherited7 = G__45;
|
|
2513
|
+
continue;
|
|
2514
|
+
} else {
|
|
2515
|
+
if (squint_core.truth_(squint_core.get(cmd_info6, "fn"))) {
|
|
2516
|
+
return ({"cmd-info": cmd_info6, "dispatch": cmds3, "opts": squint_core.dissoc(all_opts36, "babashka.cli/opts-by-cmds"), "args": args28})} else {
|
|
2517
|
+
if (squint_core.truth_(arg34)) {
|
|
2518
|
+
return ({"error": "no-match", "wrong-input": arg34, "available-commands": visible_command_names(cmd_info6), "dispatch": cmds3, "opts": squint_core.dissoc(all_opts36, "babashka.cli/opts-by-cmds")})} else {
|
|
2519
|
+
return ({"error": "input-exhausted", "available-commands": visible_command_names(cmd_info6), "dispatch": cmds3, "opts": squint_core.dissoc(all_opts36, "babashka.cli/opts-by-cmds")})}}};
|
|
2520
|
+
};
|
|
2521
|
+
;break;
|
|
2522
|
+
}
|
|
2523
|
+
;
|
|
2524
|
+
|
|
2525
|
+
});
|
|
2526
|
+
f79.cljs$lang$maxFixedArity = 3;
|
|
2527
|
+
return f79;
|
|
2528
|
+
|
|
2529
|
+
})();
|
|
2530
|
+
var dispatch_tree = (() => {
|
|
2531
|
+
const f83 = (function (...args84) {
|
|
2532
|
+
const G__851 = args84.length;
|
|
2533
|
+
switch (G__851) {case 2:
|
|
2534
|
+
return f83.cljs$core$IFn$_invoke$arity$2(args84[0], args84[1]);
|
|
2535
|
+
|
|
2536
|
+
break;
|
|
2537
|
+
case 3:
|
|
2538
|
+
return f83.cljs$core$IFn$_invoke$arity$3(args84[0], args84[1], args84[2]);
|
|
2539
|
+
|
|
2540
|
+
break;
|
|
2541
|
+
default:
|
|
2542
|
+
throw (new Error(`${"Invalid arity: "}${args84.length??''}`))};
|
|
2543
|
+
|
|
2544
|
+
});
|
|
2545
|
+
f83.cljs$core$IFn$_invoke$arity$2 = (function (tree, args) {
|
|
2546
|
+
return dispatch_tree(tree, args, null);
|
|
2547
|
+
|
|
2548
|
+
});
|
|
2549
|
+
f83.cljs$core$IFn$_invoke$arity$3 = (function (tree, args, opts) {
|
|
2550
|
+
const error_stash4 = ((squint_core.truth_(squint_core.get(opts, "babashka.cli/help"))) ? (squint_core.atom([])) : (null));
|
|
2551
|
+
const opts5 = (() => {
|
|
2552
|
+
const G__866 = opts;
|
|
2553
|
+
if (squint_core.truth_(error_stash4)) {
|
|
2554
|
+
return squint_core.assoc(G__866, "babashka.cli/error-stash", error_stash4)} else {
|
|
2555
|
+
return G__866};
|
|
2556
|
+
|
|
2557
|
+
})();
|
|
2558
|
+
const map__37 = dispatch_tree_SINGLEQUOTE_(tree, args, opts5);
|
|
2559
|
+
const res8 = map__37;
|
|
2560
|
+
const cmd_info9 = squint_core.get(map__37, "cmd-info");
|
|
2561
|
+
const error10 = squint_core.get(map__37, "error");
|
|
2562
|
+
const available_commands11 = squint_core.get(map__37, "available-commands");
|
|
2563
|
+
const error_fn12 = (() => {
|
|
2564
|
+
const or__23664__auto__13 = squint_core.get(opts5, "error-fn");
|
|
2565
|
+
if (squint_core.truth_(or__23664__auto__13)) {
|
|
2566
|
+
return or__23664__auto__13} else {
|
|
2567
|
+
return function (p__87) {
|
|
2568
|
+
const map__1415 = p__87;
|
|
2569
|
+
const data16 = map__1415;
|
|
2570
|
+
const msg17 = squint_core.get(map__1415, "msg");
|
|
2571
|
+
throw squint_core.ex_info(msg17, data16);
|
|
2572
|
+
|
|
2573
|
+
}};
|
|
2574
|
+
|
|
2575
|
+
})();
|
|
2576
|
+
if (("help" === error10)) {
|
|
2577
|
+
return squint_core.get(opts5, "babashka.cli/help-fn")(thread_dispatch_context(({...squint_core.select_keys(res8, ["dispatch"]),["tree"]:tree}), opts5))} else {
|
|
2578
|
+
if (squint_core.truth_((() => {
|
|
2579
|
+
const and__23691__auto__18 = error_stash4;
|
|
2580
|
+
if (squint_core.truth_(and__23691__auto__18)) {
|
|
2581
|
+
return squint_core.seq(squint_core.deref(error_stash4))} else {
|
|
2582
|
+
return and__23691__auto__18};
|
|
2583
|
+
|
|
2584
|
+
})())) {
|
|
2585
|
+
return squint_core.first(squint_core.deref(error_stash4))()} else {
|
|
2586
|
+
if ("else") {
|
|
2587
|
+
const G__8819 = error10;
|
|
2588
|
+
if (("no-match" === G__8819)) {
|
|
2589
|
+
return error_fn12(thread_dispatch_context(squint_core.merge(({"type": "org.babashka/cli", "cause": error10, "all-commands": available_commands11, "tree": tree}), squint_core.select_keys(res8, ["wrong-input", "opts", "dispatch"])), opts5))} else {
|
|
2590
|
+
if (("input-exhausted" === G__8819)) {
|
|
2591
|
+
return error_fn12(thread_dispatch_context(squint_core.merge(({"type": "org.babashka/cli", "cause": error10, "all-commands": available_commands11, "tree": tree}), squint_core.select_keys(res8, ["wrong-input", "opts", "dispatch"])), opts5))} else {
|
|
2592
|
+
if (squint_core._EQ_(null, G__8819)) {
|
|
2593
|
+
return squint_core.get(cmd_info9, "fn")(squint_core.dissoc(res8, "cmd-info"))} else {
|
|
2594
|
+
if ("else") {
|
|
2595
|
+
throw (new Error(`${"No matching clause: "}${G__8819??''}`))} else {
|
|
2596
|
+
return null}}}};
|
|
2597
|
+
} else {
|
|
2598
|
+
return null}}};
|
|
2599
|
+
|
|
2600
|
+
});
|
|
2601
|
+
f83.cljs$lang$maxFixedArity = 3;
|
|
2602
|
+
return f83;
|
|
2603
|
+
|
|
2604
|
+
})();
|
|
2605
|
+
var node_with_help = function (p__89) {
|
|
2606
|
+
const map__12 = p__89;
|
|
2607
|
+
const node3 = map__12;
|
|
2608
|
+
const spec4 = squint_core.get(map__12, "spec");
|
|
2609
|
+
const order5 = squint_core.get(map__12, "order");
|
|
2610
|
+
const as_map6 = __GT_spec_map(spec4);
|
|
2611
|
+
const h_free_QMARK_7 = (squint_core.not(squint_core.contains_QMARK_(as_map6, "h")) && squint_core.not(squint_core.some((function (p__90) {
|
|
2612
|
+
const vec__811 = p__90;
|
|
2613
|
+
const _12 = squint_core.nth(vec__811, 0, null);
|
|
2614
|
+
const v13 = squint_core.nth(vec__811, 1, null);
|
|
2615
|
+
const and__23691__auto__14 = squint_core.map_QMARK_(v13);
|
|
2616
|
+
if (squint_core.truth_(and__23691__auto__14)) {
|
|
2617
|
+
return ("h" === squint_core.get(v13, "alias"))} else {
|
|
2618
|
+
return and__23691__auto__14};
|
|
2619
|
+
|
|
2620
|
+
}), as_map6)));
|
|
2621
|
+
const default$15 = (() => {
|
|
2622
|
+
const G__9116 = ({"coerce": "boolean", "desc": "Show this help"});
|
|
2623
|
+
if (squint_core.truth_(h_free_QMARK_7)) {
|
|
2624
|
+
return ({...G__9116,["alias"]:"h"})} else {
|
|
2625
|
+
return G__9116};
|
|
2626
|
+
|
|
2627
|
+
})();
|
|
2628
|
+
return squint_core.assoc(node3, "spec", squint_core.update(as_map6, "help", (function (_PERCENT_1) {
|
|
2629
|
+
return squint_core.merge(default$15, _PERCENT_1);
|
|
2630
|
+
|
|
2631
|
+
})), "order", ((squint_core.truth_(order5)) ? (squint_core.vec(order5)) : ((() => {
|
|
2632
|
+
const c17 = squint_core.vec(((squint_core.truth_(squint_core.sequential_QMARK_(spec4))) ? (squint_core.map(squint_core.first, spec4)) : (squint_core.keys(as_map6))));
|
|
2633
|
+
if (squint_core.truth_(squint_core.some((new Set (["help"])), c17))) {
|
|
2634
|
+
return c17} else {
|
|
2635
|
+
return squint_core.conj(c17, "help")};
|
|
2636
|
+
|
|
2637
|
+
})())));
|
|
2638
|
+
|
|
2639
|
+
};
|
|
2640
|
+
var inject_help = function (node) {
|
|
2641
|
+
const G__921 = node_with_help(node);
|
|
2642
|
+
if (squint_core.truth_(squint_core.get(node, "cmd"))) {
|
|
2643
|
+
return squint_core.update(G__921, "cmd", (function (m) {
|
|
2644
|
+
return squint_core.reduce_kv((function (acc, k, v) {
|
|
2645
|
+
return squint_core.assoc(acc, k, inject_help(v));
|
|
2646
|
+
|
|
2647
|
+
}), ({}), m);
|
|
2648
|
+
|
|
2649
|
+
}))} else {
|
|
2650
|
+
return G__921};
|
|
2651
|
+
|
|
2652
|
+
};
|
|
2653
|
+
var drop_lone_eq = function (toks) {
|
|
2654
|
+
let acc1 = [];
|
|
2655
|
+
let s2 = squint_core.seq(toks);
|
|
2656
|
+
while(true){
|
|
2657
|
+
if (squint_core.not(s2)) {
|
|
2658
|
+
return acc1} else {
|
|
2659
|
+
const t3 = squint_core.first(s2);
|
|
2660
|
+
if (squint_core.truth_((("=" === t3) && gnu_option_QMARK_(squint_core.peek(acc1))))) {
|
|
2661
|
+
let G__4 = ((squint_core.truth_(squint_core.next(s2))) ? (acc1) : (squint_core.conj(acc1, "")));
|
|
2662
|
+
let G__5 = squint_core.next(s2);
|
|
2663
|
+
acc1 = G__4;
|
|
2664
|
+
s2 = G__5;
|
|
2665
|
+
continue;
|
|
2666
|
+
} else {
|
|
2667
|
+
let G__6 = squint_core.conj(acc1, t3);
|
|
2668
|
+
let G__7 = squint_core.next(s2);
|
|
2669
|
+
acc1 = G__6;
|
|
2670
|
+
s2 = G__7;
|
|
2671
|
+
continue;
|
|
2672
|
+
};
|
|
2673
|
+
};
|
|
2674
|
+
;break;
|
|
2675
|
+
}
|
|
2676
|
+
;
|
|
2677
|
+
|
|
2678
|
+
};
|
|
2679
|
+
var script_basename = function () {
|
|
2680
|
+
const G__931 = null;
|
|
2681
|
+
const G__932 = (((G__931 == null)) ? (null) : (str.split(G__931, /[/\\]/)));
|
|
2682
|
+
if ((G__932 == null)) {
|
|
2683
|
+
return null} else {
|
|
2684
|
+
return squint_core.last(G__932)};
|
|
2685
|
+
|
|
2686
|
+
};
|
|
2687
|
+
var completions_command = function (tree, args, opts) {
|
|
2688
|
+
const vec__19 = args;
|
|
2689
|
+
const seq__210 = squint_core.seq(vec__19);
|
|
2690
|
+
const first__311 = squint_core.first(seq__210);
|
|
2691
|
+
const seq__212 = squint_core.next(seq__210);
|
|
2692
|
+
const sub13 = first__311;
|
|
2693
|
+
const more14 = seq__212;
|
|
2694
|
+
const vec__415 = squint_core.split_with((function (_PERCENT_1) {
|
|
2695
|
+
return !("--" === _PERCENT_1);
|
|
2696
|
+
|
|
2697
|
+
}), more14);
|
|
2698
|
+
const pre16 = squint_core.nth(vec__415, 0, null);
|
|
2699
|
+
const toks17 = squint_core.nth(vec__415, 1, null);
|
|
2700
|
+
const map__718 = parse_args(squint_core.vec(pre16), ({"coerce": ({"shell": "keyword", "fresh": "boolean", "prog": []})}));
|
|
2701
|
+
const map__819 = squint_core.get(map__718, "opts");
|
|
2702
|
+
const shell20 = squint_core.get(map__819, "shell");
|
|
2703
|
+
const prog21 = squint_core.get(map__819, "prog");
|
|
2704
|
+
const fresh22 = squint_core.get(map__819, "fresh");
|
|
2705
|
+
const toks23 = squint_core.vec(squint_core.rest(toks17));
|
|
2706
|
+
const G__9424 = sub13;
|
|
2707
|
+
switch (G__9424) {case "snippet":
|
|
2708
|
+
const names26 = ((squint_core.truth_(squint_core.seq(prog21))) ? (squint_core.vec(prog21)) : (squint_core.distinct(squint_core.filter(squint_core.some_QMARK_, [squint_core.get(opts, "prog"), script_basename()]))));
|
|
2709
|
+
if (squint_core.truth_(squint_core.empty_QMARK_(names26))) {
|
|
2710
|
+
return eprintln(`${"[babashka.cli] Set :prog in opts, or pass --prog,"}${" to generate a completion snippet"}`)} else {
|
|
2711
|
+
if (squint_core.not(squint_core.get((new Set (["bash", "zsh", "fish", "powershell", "nushell"])), shell20))) {
|
|
2712
|
+
return eprintln(`${"[babashka.cli] Unknown --shell "}${squint_core.pr_str(shell20)??''}${", expected one of: bash zsh fish powershell nushell"}`)} else {
|
|
2713
|
+
if ("else") {
|
|
2714
|
+
return squint_core.print(completion_shell_snippet(shell20, names26))} else {
|
|
2715
|
+
return null}}};
|
|
2716
|
+
|
|
2717
|
+
break;
|
|
2718
|
+
case "complete":
|
|
2719
|
+
const toks27 = (() => {
|
|
2720
|
+
const G__9528 = toks23;
|
|
2721
|
+
const G__9529 = ((("bash" === shell20)) ? (drop_lone_eq(G__9528)) : (G__9528));
|
|
2722
|
+
if (squint_core.truth_(fresh22)) {
|
|
2723
|
+
return squint_core.conj(G__9529, "")} else {
|
|
2724
|
+
return G__9529};
|
|
2725
|
+
|
|
2726
|
+
})();
|
|
2727
|
+
const cands30 = complete_tree_STAR_(tree, toks27, opts);
|
|
2728
|
+
print_completions(squint_core.remove("file-completion", cands30));
|
|
2729
|
+
if (squint_core.truth_(squint_core.some("file-completion", cands30))) {
|
|
2730
|
+
return squint_core.println("org.babashka.cli/file-completion");
|
|
2731
|
+
};
|
|
2732
|
+
|
|
2733
|
+
break;
|
|
2734
|
+
default:
|
|
2735
|
+
return eprintln(`${"[babashka.cli] Expected completions command snippet or complete, got "}${squint_core.pr_str(sub13)??''}`)};
|
|
2736
|
+
|
|
2737
|
+
};
|
|
2738
|
+
var dispatch = (() => {
|
|
2739
|
+
const f96 = (function (...args97) {
|
|
2740
|
+
const G__981 = args97.length;
|
|
2741
|
+
switch (G__981) {case 2:
|
|
2742
|
+
return f96.cljs$core$IFn$_invoke$arity$2(args97[0], args97[1]);
|
|
2743
|
+
|
|
2744
|
+
break;
|
|
2745
|
+
case 3:
|
|
2746
|
+
return f96.cljs$core$IFn$_invoke$arity$3(args97[0], args97[1], args97[2]);
|
|
2747
|
+
|
|
2748
|
+
break;
|
|
2749
|
+
default:
|
|
2750
|
+
throw (new Error(`${"Invalid arity: "}${args97.length??''}`))};
|
|
2751
|
+
|
|
2752
|
+
});
|
|
2753
|
+
f96.cljs$core$IFn$_invoke$arity$2 = (function (table, args) {
|
|
2754
|
+
return dispatch(table, args, ({}));
|
|
2755
|
+
|
|
2756
|
+
});
|
|
2757
|
+
f96.cljs$core$IFn$_invoke$arity$3 = (function (table, args, opts) {
|
|
2758
|
+
const tree3 = (() => {
|
|
2759
|
+
const G__994 = table__GT_tree(table);
|
|
2760
|
+
if (squint_core.truth_(squint_core.get(opts, "help"))) {
|
|
2761
|
+
return inject_help(G__994)} else {
|
|
2762
|
+
return G__994};
|
|
2763
|
+
|
|
2764
|
+
})();
|
|
2765
|
+
if (("org.babashka.cli/completions" === squint_core.first(args))) {
|
|
2766
|
+
return completions_command(tree3, squint_core.rest(args), opts)} else {
|
|
2767
|
+
if (squint_core.truth_(squint_core.get(opts, "help"))) {
|
|
2768
|
+
return dispatch_tree(tree3, args, squint_core.assoc(opts, "babashka.cli/help", true, "error-fn", (() => {
|
|
2769
|
+
const or__23664__auto__5 = squint_core.get(opts, "error-fn");
|
|
2770
|
+
if (squint_core.truth_(or__23664__auto__5)) {
|
|
2771
|
+
return or__23664__auto__5} else {
|
|
2772
|
+
return function (p__100) {
|
|
2773
|
+
const map__67 = p__100;
|
|
2774
|
+
const data8 = map__67;
|
|
2775
|
+
const cause9 = squint_core.get(map__67, "cause");
|
|
2776
|
+
const dispatch10 = squint_core.get(map__67, "dispatch");
|
|
2777
|
+
print_command_error(data8);
|
|
2778
|
+
return _STAR_exit_fn_STAR_.val(({"exit": 1, "cause": cause9, "dispatch": dispatch10, "data": data8}));
|
|
2779
|
+
|
|
2780
|
+
}};
|
|
2781
|
+
|
|
2782
|
+
})(), "babashka.cli/help-fn", (() => {
|
|
2783
|
+
const or__23664__auto__11 = squint_core.get(opts, "help-fn");
|
|
2784
|
+
if (squint_core.truth_(or__23664__auto__11)) {
|
|
2785
|
+
return or__23664__auto__11} else {
|
|
2786
|
+
return print_command_help};
|
|
2787
|
+
|
|
2788
|
+
})()))} else {
|
|
2789
|
+
return dispatch_tree(tree3, args, opts)}};
|
|
2790
|
+
|
|
2791
|
+
});
|
|
2792
|
+
f96.cljs$lang$maxFixedArity = 3;
|
|
2793
|
+
return f96;
|
|
2794
|
+
|
|
2795
|
+
})();
|
|
2796
|
+
|
|
2797
|
+
export { pad, dispatch, parse_opts, table__GT_tree, format_table, parse_args, complete_tree_STAR_, number_char_QMARK_, opts__GT_table, validate_opts, format_command_error, cmd_children, format_command_help, apply_defaults, coerce_opts, parse_keyword, spec__GT_opts, auto_coerce, parse_opts_STAR_, merge_opts, parse_cmds, format_opts, _STAR_exit_fn_STAR_, pad_cells, __GT_Injected, coerce, default_width_fn }
|