@qodalis/cli-string 0.0.2 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/public-api.js ADDED
@@ -0,0 +1,775 @@
1
+ 'use strict';
2
+
3
+ var cliCore = require('@qodalis/cli-core');
4
+ var _ = require('lodash');
5
+
6
+ function _interopNamespace(e) {
7
+ if (e && e.__esModule) return e;
8
+ var n = Object.create(null);
9
+ if (e) {
10
+ Object.keys(e).forEach(function (k) {
11
+ if (k !== 'default') {
12
+ var d = Object.getOwnPropertyDescriptor(e, k);
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: function () { return e[k]; }
16
+ });
17
+ }
18
+ });
19
+ }
20
+ n.default = e;
21
+ return Object.freeze(n);
22
+ }
23
+
24
+ var ___namespace = /*#__PURE__*/_interopNamespace(_);
25
+
26
+ // src/lib/processors/cli-string-command-processor.ts
27
+
28
+ // src/lib/version.ts
29
+ var LIBRARY_VERSION = "2.0.0-beta.1";
30
+ var API_VERSION = 2;
31
+
32
+ // src/lib/processors/cli-string-command-processor.ts
33
+ var lodash = ___namespace.default || ___namespace;
34
+ function stringTransform(command, description, transform, options) {
35
+ return {
36
+ command,
37
+ aliases: options?.aliases,
38
+ description,
39
+ acceptsRawInput: true,
40
+ valueRequired: true,
41
+ processCommand: async (cmd, context) => {
42
+ const text = cmd.value || cmd.data || "";
43
+ const result = transform(text);
44
+ context.writer.writeln(
45
+ `${context.writer.wrapInColor("Result: ", cliCore.CliForegroundColor.Yellow)}${result}`
46
+ );
47
+ context.process.output(result);
48
+ },
49
+ writeDescription: (context) => {
50
+ const { writer } = context;
51
+ writer.writeln(description);
52
+ writer.writeln();
53
+ writer.writeln("\u{1F4CB} Usage:");
54
+ writer.writeln(
55
+ ` ${writer.wrapInColor(`string ${command} <text>`, cliCore.CliForegroundColor.Cyan)}`
56
+ );
57
+ if (options?.example) {
58
+ writer.writeln();
59
+ writer.writeln("\u{1F4DD} Examples:");
60
+ writer.writeln(
61
+ ` string ${command} ${options.example.input.padEnd(20)} ${writer.wrapInColor(`# \u2192 ${options.example.output}`, cliCore.CliForegroundColor.Green)}`
62
+ );
63
+ }
64
+ }
65
+ };
66
+ }
67
+ var CliStringCommandProcessor = class {
68
+ constructor() {
69
+ this.command = "string";
70
+ this.aliases = ["str"];
71
+ this.description = "String manipulation commands";
72
+ this.author = cliCore.DefaultLibraryAuthor;
73
+ this.version = LIBRARY_VERSION;
74
+ this.processors = [];
75
+ this.metadata = {
76
+ icon: "\u{1F524}",
77
+ requiredCoreVersion: ">=2.0.0 <3.0.0",
78
+ requiredCliVersion: ">=2.0.0 <3.0.0"
79
+ };
80
+ this.processors = [
81
+ // -- Case conversions --
82
+ stringTransform(
83
+ "upper",
84
+ "Convert to UPPERCASE",
85
+ (t) => t.toUpperCase(),
86
+ {
87
+ aliases: ["uppercase", "toUpper"],
88
+ example: { input: "hello world", output: "HELLO WORLD" }
89
+ }
90
+ ),
91
+ stringTransform(
92
+ "lower",
93
+ "Convert to lowercase",
94
+ (t) => t.toLowerCase(),
95
+ {
96
+ aliases: ["lowercase", "toLower"],
97
+ example: { input: "HELLO WORLD", output: "hello world" }
98
+ }
99
+ ),
100
+ stringTransform(
101
+ "capitalize",
102
+ "Capitalize the first letter",
103
+ (t) => lodash.capitalize(t),
104
+ {
105
+ aliases: ["cap"],
106
+ example: { input: "hello world", output: "Hello world" }
107
+ }
108
+ ),
109
+ stringTransform(
110
+ "camelCase",
111
+ "Convert to camelCase",
112
+ (t) => lodash.camelCase(t),
113
+ {
114
+ aliases: ["camel"],
115
+ example: { input: "hello world", output: "helloWorld" }
116
+ }
117
+ ),
118
+ stringTransform(
119
+ "kebabCase",
120
+ "Convert to kebab-case",
121
+ (t) => lodash.kebabCase(t),
122
+ {
123
+ aliases: ["kebab"],
124
+ example: { input: "Hello World", output: "hello-world" }
125
+ }
126
+ ),
127
+ stringTransform(
128
+ "snakeCase",
129
+ "Convert to snake_case",
130
+ (t) => lodash.snakeCase(t),
131
+ {
132
+ aliases: ["snake"],
133
+ example: { input: "Hello World", output: "hello_world" }
134
+ }
135
+ ),
136
+ stringTransform(
137
+ "startCase",
138
+ "Convert to Start Case",
139
+ (t) => lodash.startCase(t),
140
+ {
141
+ aliases: ["title", "titleCase"],
142
+ example: { input: "hello-world", output: "Hello World" }
143
+ }
144
+ ),
145
+ // -- Trimming --
146
+ stringTransform(
147
+ "trim",
148
+ "Remove whitespace from both ends",
149
+ (t) => t.trim(),
150
+ {
151
+ example: { input: '" hello "', output: "hello" }
152
+ }
153
+ ),
154
+ stringTransform(
155
+ "trimStart",
156
+ "Remove whitespace from the start",
157
+ (t) => t.trimStart(),
158
+ {
159
+ aliases: ["ltrim"],
160
+ example: { input: '" hello"', output: "hello" }
161
+ }
162
+ ),
163
+ stringTransform(
164
+ "trimEnd",
165
+ "Remove whitespace from the end",
166
+ (t) => t.trimEnd(),
167
+ {
168
+ aliases: ["rtrim"],
169
+ example: { input: '"hello "', output: "hello" }
170
+ }
171
+ ),
172
+ // -- Transform --
173
+ stringTransform(
174
+ "reverse",
175
+ "Reverse a string",
176
+ (t) => [...t].reverse().join(""),
177
+ {
178
+ aliases: ["rev"],
179
+ example: { input: "Hello", output: "olleH" }
180
+ }
181
+ ),
182
+ stringTransform(
183
+ "slug",
184
+ "Convert to URL-friendly slug",
185
+ (t) => t.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, ""),
186
+ {
187
+ aliases: ["slugify"],
188
+ example: { input: '"Hello World!"', output: "hello-world" }
189
+ }
190
+ ),
191
+ stringTransform(
192
+ "escape",
193
+ "Escape HTML entities",
194
+ (t) => lodash.escape(t),
195
+ {
196
+ aliases: ["escapeHtml"],
197
+ example: {
198
+ input: '"<b>hi</b>"',
199
+ output: "&lt;b&gt;hi&lt;/b&gt;"
200
+ }
201
+ }
202
+ ),
203
+ stringTransform(
204
+ "unescape",
205
+ "Unescape HTML entities",
206
+ (t) => lodash.unescape(t),
207
+ {
208
+ aliases: ["unescapeHtml"],
209
+ example: { input: '"&lt;b&gt;"', output: "<b>" }
210
+ }
211
+ ),
212
+ // -- Repeat --
213
+ {
214
+ command: "repeat",
215
+ description: "Repeat a string N times",
216
+ acceptsRawInput: true,
217
+ valueRequired: true,
218
+ parameters: [
219
+ {
220
+ name: "count",
221
+ aliases: ["n"],
222
+ description: "Number of repetitions (default: 2)",
223
+ type: "number",
224
+ required: false
225
+ },
226
+ {
227
+ name: "separator",
228
+ aliases: ["sep"],
229
+ description: "Separator between repetitions (default: none)",
230
+ type: "string",
231
+ required: false
232
+ }
233
+ ],
234
+ processCommand: async (command, context) => {
235
+ const text = command.value || command.data || "";
236
+ const count = Math.min(
237
+ parseInt(command.args["count"] || command.args["n"]) || 2,
238
+ 1e3
239
+ );
240
+ const sep = command.args["separator"] || command.args["sep"] || "";
241
+ const result = Array(count).fill(text).join(sep);
242
+ context.writer.writeln(
243
+ `${context.writer.wrapInColor("Result: ", cliCore.CliForegroundColor.Yellow)}${result}`
244
+ );
245
+ context.process.output(result);
246
+ },
247
+ writeDescription: (context) => {
248
+ const { writer } = context;
249
+ writer.writeln("Repeat a string multiple times");
250
+ writer.writeln();
251
+ writer.writeln("\u{1F4CB} Usage:");
252
+ writer.writeln(
253
+ ` ${writer.wrapInColor("string repeat <text> [--count=N] [--sep=S]", cliCore.CliForegroundColor.Cyan)}`
254
+ );
255
+ writer.writeln();
256
+ writer.writeln("\u{1F4DD} Examples:");
257
+ writer.writeln(
258
+ ` string repeat ha --count=3 ${writer.wrapInColor("# \u2192 hahaha", cliCore.CliForegroundColor.Green)}`
259
+ );
260
+ writer.writeln(
261
+ ` string repeat ab --n=3 --sep=- ${writer.wrapInColor("# \u2192 ab-ab-ab", cliCore.CliForegroundColor.Green)}`
262
+ );
263
+ }
264
+ },
265
+ // -- Replace --
266
+ {
267
+ command: "replace",
268
+ description: "Replace occurrences in a string",
269
+ acceptsRawInput: true,
270
+ valueRequired: true,
271
+ parameters: [
272
+ {
273
+ name: "find",
274
+ aliases: ["f"],
275
+ description: "Text to find",
276
+ type: "string",
277
+ required: true
278
+ },
279
+ {
280
+ name: "with",
281
+ aliases: ["w"],
282
+ description: "Replacement text",
283
+ type: "string",
284
+ required: true
285
+ }
286
+ ],
287
+ processCommand: async (command, context) => {
288
+ const text = command.value || command.data || "";
289
+ const find = command.args["find"] || command.args["f"] || "";
290
+ const replacement = command.args["with"] || command.args["w"] || "";
291
+ if (!find) {
292
+ context.writer.writeError("--find is required");
293
+ context.process.exit(-1);
294
+ return;
295
+ }
296
+ const result = text.split(find).join(replacement);
297
+ context.writer.writeln(
298
+ `${context.writer.wrapInColor("Result: ", cliCore.CliForegroundColor.Yellow)}${result}`
299
+ );
300
+ context.process.output(result);
301
+ },
302
+ writeDescription: (context) => {
303
+ const { writer } = context;
304
+ writer.writeln("Replace all occurrences of a substring");
305
+ writer.writeln();
306
+ writer.writeln("\u{1F4CB} Usage:");
307
+ writer.writeln(
308
+ ` ${writer.wrapInColor("string replace <text> --find=<search> --with=<replacement>", cliCore.CliForegroundColor.Cyan)}`
309
+ );
310
+ writer.writeln();
311
+ writer.writeln("\u{1F4DD} Examples:");
312
+ writer.writeln(
313
+ ` string replace "hello world" --find=world --with=there`
314
+ );
315
+ writer.writeln(
316
+ ` ${writer.wrapInColor("# \u2192 hello there", cliCore.CliForegroundColor.Green)}`
317
+ );
318
+ }
319
+ },
320
+ // -- Truncate --
321
+ {
322
+ command: "truncate",
323
+ aliases: ["trunc"],
324
+ description: "Truncate a string to a max length",
325
+ acceptsRawInput: true,
326
+ valueRequired: true,
327
+ parameters: [
328
+ {
329
+ name: "length",
330
+ aliases: ["l"],
331
+ description: "Maximum length (default: 30)",
332
+ type: "number",
333
+ required: false
334
+ },
335
+ {
336
+ name: "suffix",
337
+ description: "Omission suffix (default: ...)",
338
+ type: "string",
339
+ required: false
340
+ }
341
+ ],
342
+ processCommand: async (command, context) => {
343
+ const text = command.value || command.data || "";
344
+ const length = parseInt(command.args["length"] || command.args["l"]) || 30;
345
+ const suffix = command.args["suffix"] ?? "...";
346
+ const result = text.length > length ? text.substring(0, length - suffix.length) + suffix : text;
347
+ context.writer.writeln(
348
+ `${context.writer.wrapInColor("Result: ", cliCore.CliForegroundColor.Yellow)}${result}`
349
+ );
350
+ context.process.output(result);
351
+ },
352
+ writeDescription: (context) => {
353
+ const { writer } = context;
354
+ writer.writeln(
355
+ "Truncate a string to a maximum length with an ellipsis"
356
+ );
357
+ writer.writeln();
358
+ writer.writeln("\u{1F4CB} Usage:");
359
+ writer.writeln(
360
+ ` ${writer.wrapInColor("string truncate <text> [--length=N] [--suffix=S]", cliCore.CliForegroundColor.Cyan)}`
361
+ );
362
+ }
363
+ },
364
+ // -- Pad --
365
+ {
366
+ command: "pad",
367
+ description: "Pad a string to a target length",
368
+ acceptsRawInput: true,
369
+ valueRequired: true,
370
+ parameters: [
371
+ {
372
+ name: "length",
373
+ aliases: ["l"],
374
+ description: "Target length",
375
+ type: "number",
376
+ required: true
377
+ },
378
+ {
379
+ name: "char",
380
+ aliases: ["c"],
381
+ description: "Padding character (default: space)",
382
+ type: "string",
383
+ required: false
384
+ },
385
+ {
386
+ name: "side",
387
+ description: "Pad side: left, right, both (default: both)",
388
+ type: "string",
389
+ required: false
390
+ }
391
+ ],
392
+ processCommand: async (command, context) => {
393
+ const text = command.value || command.data || "";
394
+ const length = parseInt(
395
+ command.args["length"] || command.args["l"]
396
+ );
397
+ const char = command.args["char"] || command.args["c"] || " ";
398
+ const side = command.args["side"] || "both";
399
+ if (isNaN(length)) {
400
+ context.writer.writeError("--length is required");
401
+ context.process.exit(-1);
402
+ return;
403
+ }
404
+ let result;
405
+ switch (side) {
406
+ case "left":
407
+ case "start":
408
+ result = text.padStart(length, char);
409
+ break;
410
+ case "right":
411
+ case "end":
412
+ result = text.padEnd(length, char);
413
+ break;
414
+ default:
415
+ result = lodash.pad(text, length, char);
416
+ break;
417
+ }
418
+ context.writer.writeln(
419
+ `${context.writer.wrapInColor("Result: ", cliCore.CliForegroundColor.Yellow)}"${result}"`
420
+ );
421
+ context.process.output(result);
422
+ },
423
+ writeDescription: (context) => {
424
+ const { writer } = context;
425
+ writer.writeln("Pad a string to a target length");
426
+ writer.writeln();
427
+ writer.writeln("\u{1F4CB} Usage:");
428
+ writer.writeln(
429
+ ` ${writer.wrapInColor("string pad <text> --length=N [--char=C] [--side=left|right|both]", cliCore.CliForegroundColor.Cyan)}`
430
+ );
431
+ writer.writeln();
432
+ writer.writeln("\u{1F4DD} Examples:");
433
+ writer.writeln(
434
+ ` string pad hello --length=10 --char=. --side=right`
435
+ );
436
+ writer.writeln(
437
+ ` ${writer.wrapInColor('# \u2192 "hello....."', cliCore.CliForegroundColor.Green)}`
438
+ );
439
+ }
440
+ },
441
+ // -- Split --
442
+ {
443
+ command: "split",
444
+ description: "Split a string by a delimiter",
445
+ acceptsRawInput: true,
446
+ valueRequired: true,
447
+ parameters: [
448
+ {
449
+ name: "by",
450
+ aliases: ["d", "delimiter"],
451
+ description: "Delimiter to split by (default: space)",
452
+ type: "string",
453
+ required: false
454
+ }
455
+ ],
456
+ processCommand: async (command, context) => {
457
+ const text = command.value || command.data || "";
458
+ const delimiter = command.args["by"] || command.args["d"] || command.args["delimiter"] || " ";
459
+ const parts = text.split(delimiter);
460
+ const { writer } = context;
461
+ parts.forEach((part, i) => {
462
+ writer.writeln(
463
+ ` ${writer.wrapInColor(String(i).padStart(3), cliCore.CliForegroundColor.Yellow)} ${part}`
464
+ );
465
+ });
466
+ context.process.output(parts);
467
+ },
468
+ writeDescription: (context) => {
469
+ const { writer } = context;
470
+ writer.writeln("Split a string into parts by a delimiter");
471
+ writer.writeln();
472
+ writer.writeln("\u{1F4CB} Usage:");
473
+ writer.writeln(
474
+ ` ${writer.wrapInColor("string split <text> [--by=<delimiter>]", cliCore.CliForegroundColor.Cyan)}`
475
+ );
476
+ writer.writeln();
477
+ writer.writeln("\u{1F4DD} Examples:");
478
+ writer.writeln(
479
+ ` string split "a,b,c" --by=, ${writer.wrapInColor("# \u2192 a b c", cliCore.CliForegroundColor.Green)}`
480
+ );
481
+ }
482
+ },
483
+ // -- Words --
484
+ {
485
+ command: "words",
486
+ description: "Split a string into words",
487
+ acceptsRawInput: true,
488
+ valueRequired: true,
489
+ processCommand: async (command, context) => {
490
+ const text = command.value || command.data || "";
491
+ const words = lodash.words(text);
492
+ const { writer } = context;
493
+ writer.writeln(
494
+ `${writer.wrapInColor(`${words.length} words:`, cliCore.CliForegroundColor.Yellow)} ${words.join(", ")}`
495
+ );
496
+ context.process.output(words);
497
+ },
498
+ writeDescription: (context) => {
499
+ const { writer } = context;
500
+ writer.writeln("Split a string into its component words");
501
+ writer.writeln();
502
+ writer.writeln("\u{1F4CB} Usage:");
503
+ writer.writeln(
504
+ ` ${writer.wrapInColor("string words <text>", cliCore.CliForegroundColor.Cyan)}`
505
+ );
506
+ writer.writeln();
507
+ writer.writeln("\u{1F4DD} Examples:");
508
+ writer.writeln(
509
+ ` string words "helloWorld" ${writer.wrapInColor("# \u2192 hello, World", cliCore.CliForegroundColor.Green)}`
510
+ );
511
+ writer.writeln(
512
+ ` string words "foo-bar_baz" ${writer.wrapInColor("# \u2192 foo, bar, baz", cliCore.CliForegroundColor.Green)}`
513
+ );
514
+ }
515
+ },
516
+ // -- Analysis --
517
+ {
518
+ command: "length",
519
+ aliases: ["len"],
520
+ description: "Get the length of a string",
521
+ acceptsRawInput: true,
522
+ valueRequired: true,
523
+ processCommand: async (command, context) => {
524
+ const text = command.value || command.data || "";
525
+ context.writer.writeln(
526
+ `${context.writer.wrapInColor("Result: ", cliCore.CliForegroundColor.Yellow)}${text.length}`
527
+ );
528
+ context.process.output(text.length);
529
+ },
530
+ writeDescription: (context) => {
531
+ const { writer } = context;
532
+ writer.writeln("Get the character count of a string");
533
+ writer.writeln();
534
+ writer.writeln("\u{1F4CB} Usage:");
535
+ writer.writeln(
536
+ ` ${writer.wrapInColor("string length <text>", cliCore.CliForegroundColor.Cyan)}`
537
+ );
538
+ }
539
+ },
540
+ {
541
+ command: "wc",
542
+ aliases: ["wordcount", "count"],
543
+ description: "Count lines, words, characters, and bytes",
544
+ acceptsRawInput: true,
545
+ valueRequired: true,
546
+ processCommand: async (command, context) => {
547
+ const text = command.value || command.data || "";
548
+ const { writer } = context;
549
+ const lines = text.split(/\r?\n/).length;
550
+ const wordCount = text.trim() ? text.trim().split(/\s+/).length : 0;
551
+ const chars = text.length;
552
+ const bytes = new TextEncoder().encode(text).length;
553
+ writer.writeln(
554
+ ` ${writer.wrapInColor("Lines:", cliCore.CliForegroundColor.Cyan)} ${lines}`
555
+ );
556
+ writer.writeln(
557
+ ` ${writer.wrapInColor("Words:", cliCore.CliForegroundColor.Cyan)} ${wordCount}`
558
+ );
559
+ writer.writeln(
560
+ ` ${writer.wrapInColor("Characters:", cliCore.CliForegroundColor.Cyan)} ${chars}`
561
+ );
562
+ writer.writeln(
563
+ ` ${writer.wrapInColor("Bytes:", cliCore.CliForegroundColor.Cyan)} ${bytes}`
564
+ );
565
+ context.process.output({
566
+ lines,
567
+ words: wordCount,
568
+ chars,
569
+ bytes
570
+ });
571
+ },
572
+ writeDescription: (context) => {
573
+ const { writer } = context;
574
+ writer.writeln(
575
+ "Count lines, words, characters, and bytes in text"
576
+ );
577
+ writer.writeln();
578
+ writer.writeln("\u{1F4CB} Usage:");
579
+ writer.writeln(
580
+ ` ${writer.wrapInColor("string wc <text>", cliCore.CliForegroundColor.Cyan)}`
581
+ );
582
+ }
583
+ },
584
+ {
585
+ command: "includes",
586
+ aliases: ["contains", "has"],
587
+ description: "Check if a string contains a substring",
588
+ acceptsRawInput: true,
589
+ valueRequired: true,
590
+ parameters: [
591
+ {
592
+ name: "find",
593
+ aliases: ["f"],
594
+ description: "Substring to search for",
595
+ type: "string",
596
+ required: true
597
+ }
598
+ ],
599
+ processCommand: async (command, context) => {
600
+ const text = command.value || command.data || "";
601
+ const find = command.args["find"] || command.args["f"] || "";
602
+ const result = text.includes(find);
603
+ const { writer } = context;
604
+ if (result) {
605
+ writer.writeSuccess(`"${find}" found in string`);
606
+ } else {
607
+ writer.writeError(`"${find}" not found in string`);
608
+ }
609
+ context.process.output(result);
610
+ },
611
+ writeDescription: (context) => {
612
+ const { writer } = context;
613
+ writer.writeln(
614
+ "Check if a string contains a given substring"
615
+ );
616
+ writer.writeln();
617
+ writer.writeln("\u{1F4CB} Usage:");
618
+ writer.writeln(
619
+ ` ${writer.wrapInColor("string includes <text> --find=<substring>", cliCore.CliForegroundColor.Cyan)}`
620
+ );
621
+ }
622
+ },
623
+ {
624
+ command: "startsWith",
625
+ description: "Check if a string starts with a prefix",
626
+ acceptsRawInput: true,
627
+ valueRequired: true,
628
+ parameters: [
629
+ {
630
+ name: "find",
631
+ aliases: ["f"],
632
+ description: "Prefix to check",
633
+ type: "string",
634
+ required: true
635
+ }
636
+ ],
637
+ processCommand: async (command, context) => {
638
+ const text = command.value || command.data || "";
639
+ const find = command.args["find"] || command.args["f"] || "";
640
+ const result = text.startsWith(find);
641
+ const { writer } = context;
642
+ writer.writeln(
643
+ `${writer.wrapInColor("Result: ", cliCore.CliForegroundColor.Yellow)}${result}`
644
+ );
645
+ context.process.output(result);
646
+ },
647
+ writeDescription: (context) => {
648
+ const { writer } = context;
649
+ writer.writeln(
650
+ "Check if a string starts with a given prefix"
651
+ );
652
+ writer.writeln();
653
+ writer.writeln("\u{1F4CB} Usage:");
654
+ writer.writeln(
655
+ ` ${writer.wrapInColor("string startsWith <text> --find=<prefix>", cliCore.CliForegroundColor.Cyan)}`
656
+ );
657
+ }
658
+ },
659
+ {
660
+ command: "endsWith",
661
+ description: "Check if a string ends with a suffix",
662
+ acceptsRawInput: true,
663
+ valueRequired: true,
664
+ parameters: [
665
+ {
666
+ name: "find",
667
+ aliases: ["f"],
668
+ description: "Suffix to check",
669
+ type: "string",
670
+ required: true
671
+ }
672
+ ],
673
+ processCommand: async (command, context) => {
674
+ const text = command.value || command.data || "";
675
+ const find = command.args["find"] || command.args["f"] || "";
676
+ const result = text.endsWith(find);
677
+ const { writer } = context;
678
+ writer.writeln(
679
+ `${writer.wrapInColor("Result: ", cliCore.CliForegroundColor.Yellow)}${result}`
680
+ );
681
+ context.process.output(result);
682
+ },
683
+ writeDescription: (context) => {
684
+ const { writer } = context;
685
+ writer.writeln(
686
+ "Check if a string ends with a given suffix"
687
+ );
688
+ writer.writeln();
689
+ writer.writeln("\u{1F4CB} Usage:");
690
+ writer.writeln(
691
+ ` ${writer.wrapInColor("string endsWith <text> --find=<suffix>", cliCore.CliForegroundColor.Cyan)}`
692
+ );
693
+ }
694
+ }
695
+ ];
696
+ }
697
+ async processCommand(command, context) {
698
+ context.executor.showHelp(command, context);
699
+ }
700
+ writeDescription(context) {
701
+ const { writer } = context;
702
+ writer.writeln("String manipulation and analysis commands");
703
+ writer.writeln();
704
+ writer.writeln(
705
+ writer.wrapInColor(
706
+ "\u{1F520} Case Conversions:",
707
+ cliCore.CliForegroundColor.Yellow
708
+ )
709
+ );
710
+ writer.writeln(
711
+ ` ${writer.wrapInColor("string upper", cliCore.CliForegroundColor.Cyan)} / ${writer.wrapInColor("lower", cliCore.CliForegroundColor.Cyan)} / ${writer.wrapInColor("capitalize", cliCore.CliForegroundColor.Cyan)}`
712
+ );
713
+ writer.writeln(
714
+ ` ${writer.wrapInColor("string camelCase", cliCore.CliForegroundColor.Cyan)} / ${writer.wrapInColor("kebabCase", cliCore.CliForegroundColor.Cyan)} / ${writer.wrapInColor("snakeCase", cliCore.CliForegroundColor.Cyan)} / ${writer.wrapInColor("startCase", cliCore.CliForegroundColor.Cyan)}`
715
+ );
716
+ writer.writeln();
717
+ writer.writeln(
718
+ writer.wrapInColor("\u{1F527} Transform:", cliCore.CliForegroundColor.Yellow)
719
+ );
720
+ writer.writeln(
721
+ ` ${writer.wrapInColor("string reverse", cliCore.CliForegroundColor.Cyan)} / ${writer.wrapInColor("trim", cliCore.CliForegroundColor.Cyan)} / ${writer.wrapInColor("slug", cliCore.CliForegroundColor.Cyan)} / ${writer.wrapInColor("repeat", cliCore.CliForegroundColor.Cyan)} / ${writer.wrapInColor("replace", cliCore.CliForegroundColor.Cyan)} / ${writer.wrapInColor("truncate", cliCore.CliForegroundColor.Cyan)}`
722
+ );
723
+ writer.writeln(
724
+ ` ${writer.wrapInColor("string pad", cliCore.CliForegroundColor.Cyan)} / ${writer.wrapInColor("escape", cliCore.CliForegroundColor.Cyan)} / ${writer.wrapInColor("unescape", cliCore.CliForegroundColor.Cyan)}`
725
+ );
726
+ writer.writeln();
727
+ writer.writeln(
728
+ writer.wrapInColor("\u{1F50D} Analysis:", cliCore.CliForegroundColor.Yellow)
729
+ );
730
+ writer.writeln(
731
+ ` ${writer.wrapInColor("string length", cliCore.CliForegroundColor.Cyan)} / ${writer.wrapInColor("wc", cliCore.CliForegroundColor.Cyan)} / ${writer.wrapInColor("includes", cliCore.CliForegroundColor.Cyan)} / ${writer.wrapInColor("startsWith", cliCore.CliForegroundColor.Cyan)} / ${writer.wrapInColor("endsWith", cliCore.CliForegroundColor.Cyan)}`
732
+ );
733
+ writer.writeln(
734
+ ` ${writer.wrapInColor("string split", cliCore.CliForegroundColor.Cyan)} / ${writer.wrapInColor("words", cliCore.CliForegroundColor.Cyan)}`
735
+ );
736
+ writer.writeln();
737
+ writer.writeln("\u{1F4DD} Examples:");
738
+ writer.writeln(
739
+ ` string camelCase "hello world" ${writer.wrapInColor("# \u2192 helloWorld", cliCore.CliForegroundColor.Green)}`
740
+ );
741
+ writer.writeln(
742
+ ` string reverse Hello ${writer.wrapInColor("# \u2192 olleH", cliCore.CliForegroundColor.Green)}`
743
+ );
744
+ writer.writeln(
745
+ ` string slug "Hello World!" ${writer.wrapInColor("# \u2192 hello-world", cliCore.CliForegroundColor.Green)}`
746
+ );
747
+ writer.writeln(
748
+ ` string wc "some text here" ${writer.wrapInColor("# word/char counts", cliCore.CliForegroundColor.Green)}`
749
+ );
750
+ }
751
+ };
752
+
753
+ // src/public-api.ts
754
+ var stringModule = {
755
+ apiVersion: API_VERSION,
756
+ name: "@qodalis/cli-string",
757
+ processors: [new CliStringCommandProcessor()],
758
+ translations: {
759
+ es: { "cli.string.description": "Utilidades de transformaci\xF3n de cadenas" },
760
+ fr: { "cli.string.description": "Utilitaires de transformation de cha\xEEnes" },
761
+ de: { "cli.string.description": "Zeichenketten-Transformationswerkzeuge" },
762
+ pt: { "cli.string.description": "Utilit\xE1rios de transforma\xE7\xE3o de strings" },
763
+ it: { "cli.string.description": "Utilit\xE0 di trasformazione stringhe" },
764
+ ja: { "cli.string.description": "\u6587\u5B57\u5217\u5909\u63DB\u30E6\u30FC\u30C6\u30A3\u30EA\u30C6\u30A3" },
765
+ ko: { "cli.string.description": "\uBB38\uC790\uC5F4 \uBCC0\uD658 \uC720\uD2F8\uB9AC\uD2F0" },
766
+ zh: { "cli.string.description": "\u5B57\u7B26\u4E32\u8F6C\u6362\u5DE5\u5177" },
767
+ ru: { "cli.string.description": "\u0423\u0442\u0438\u043B\u0438\u0442\u044B \u043F\u0440\u0435\u043E\u0431\u0440\u0430\u0437\u043E\u0432\u0430\u043D\u0438\u044F \u0441\u0442\u0440\u043E\u043A" },
768
+ ro: { "cli.string.description": "Utilitare de transformare a \u0219irurilor de caractere" }
769
+ }
770
+ };
771
+
772
+ exports.CliStringCommandProcessor = CliStringCommandProcessor;
773
+ exports.stringModule = stringModule;
774
+ //# sourceMappingURL=public-api.js.map
775
+ //# sourceMappingURL=public-api.js.map