cli-kiss 0.2.6 → 0.2.8

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.
Files changed (39) hide show
  1. package/README.md +62 -4
  2. package/dist/index.d.ts +135 -128
  3. package/dist/index.js +2 -2
  4. package/dist/index.js.map +1 -1
  5. package/docs/.vitepress/config.mts +1 -1
  6. package/docs/.vitepress/theme/Layout.vue +16 -0
  7. package/docs/.vitepress/theme/index.ts +5 -1
  8. package/docs/.vitepress/theme/style.css +5 -1
  9. package/docs/guide/02_commands.md +1 -1
  10. package/docs/guide/03_options.md +11 -11
  11. package/docs/guide/05_input_types.md +9 -10
  12. package/docs/guide/06_run_as_cli.md +1 -1
  13. package/docs/index.md +2 -2
  14. package/docs/public/favicon.ico +0 -0
  15. package/docs/public/logo.png +0 -0
  16. package/package.json +1 -1
  17. package/src/index.ts +1 -0
  18. package/src/lib/Command.ts +50 -30
  19. package/src/lib/Operation.ts +29 -21
  20. package/src/lib/Option.ts +198 -133
  21. package/src/lib/Positional.ts +46 -24
  22. package/src/lib/Reader.ts +194 -207
  23. package/src/lib/Run.ts +19 -8
  24. package/src/lib/Suggest.ts +78 -0
  25. package/src/lib/Type.ts +46 -48
  26. package/src/lib/Typo.ts +72 -47
  27. package/src/lib/Usage.ts +13 -13
  28. package/tests/unit.Reader.commons.ts +92 -116
  29. package/tests/unit.Reader.parsings.ts +14 -26
  30. package/tests/unit.Reader.shortBig.ts +81 -96
  31. package/tests/unit.command.aliases.ts +100 -0
  32. package/tests/unit.command.execute.ts +1 -1
  33. package/tests/unit.command.usage.ts +12 -6
  34. package/tests/unit.fuzzed.alternatives.ts +43 -0
  35. package/tests/unit.runner.colors.ts +11 -35
  36. package/tests/unit.runner.cycle.ts +181 -128
  37. package/tests/unit.runner.errors.ts +26 -19
  38. package/docs/public/hero.png +0 -0
  39. package/tests/unit.Reader.aliases.ts +0 -62
@@ -1,62 +0,0 @@
1
- import { expect, it } from "@jest/globals";
2
- import { ReaderArgs, ReaderOptionParsing } from "../src";
3
-
4
- it("run", async function () {
5
- const readerArgs = new ReaderArgs([
6
- "--option=1.1",
7
- "--option-alias1=1.2",
8
- "--option-alias2",
9
- "1.3",
10
- "-pts=1.4",
11
- "-o",
12
- "1.5",
13
- "--flag1-alias",
14
- "-fa2=woops",
15
- "-fa2o=1.6",
16
- ]);
17
-
18
- const kOption = readerArgs.registerOption({
19
- longs: ["option", "option-alias1", "option-alias2"],
20
- shorts: ["pts", "o"],
21
- parsing: optionValueFixedUniqueParsing,
22
- });
23
- const kFlag1 = readerArgs.registerOption({
24
- longs: ["flag1", "flag1-alias"],
25
- shorts: [],
26
- parsing: optionFlagParsing,
27
- });
28
- const kFlag2 = readerArgs.registerOption({
29
- longs: ["flag2"],
30
- shorts: ["fa2"],
31
- parsing: optionFlagParsing,
32
- });
33
-
34
- expect(readerArgs.consumePositional()).toStrictEqual(undefined);
35
-
36
- expect(readerArgs.getOptionValues(kOption)).toStrictEqual([
37
- { inlined: "1.1", separated: [] },
38
- { inlined: "1.2", separated: [] },
39
- { inlined: null, separated: ["1.3"] },
40
- { inlined: "1.4", separated: [] },
41
- { inlined: null, separated: ["1.5"] },
42
- { inlined: "1.6", separated: [] },
43
- ]);
44
- expect(readerArgs.getOptionValues(kFlag1)).toStrictEqual([
45
- { inlined: null, separated: [] },
46
- ]);
47
- expect(readerArgs.getOptionValues(kFlag2)).toStrictEqual([
48
- { inlined: "woops", separated: [] },
49
- { inlined: null, separated: [] },
50
- ]);
51
- });
52
-
53
- const optionFlagParsing: ReaderOptionParsing = {
54
- consumeShortGroup: false,
55
- consumeNextArg: () => false,
56
- };
57
-
58
- const optionValueFixedUniqueParsing: ReaderOptionParsing = {
59
- consumeShortGroup: true,
60
- consumeNextArg: (inlined, separated) =>
61
- inlined === null && separated.length === 0,
62
- };