talented-args 0.2.4-beta → 0.3.0-beta

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 (70) hide show
  1. package/README.md +497 -10
  2. package/dist/clipboard.d.ts +10 -0
  3. package/dist/clipboard.js +79 -0
  4. package/dist/clipboard.js.map +1 -0
  5. package/dist/compile.d.ts +67 -0
  6. package/dist/compile.js +188 -0
  7. package/dist/compile.js.map +1 -0
  8. package/dist/descriptors.d.ts +322 -0
  9. package/dist/descriptors.js +362 -0
  10. package/dist/descriptors.js.map +1 -0
  11. package/dist/display.d.ts +31 -0
  12. package/dist/display.js +235 -0
  13. package/dist/display.js.map +1 -0
  14. package/dist/errors.d.ts +34 -17
  15. package/dist/errors.js +61 -75
  16. package/dist/errors.js.map +1 -1
  17. package/dist/index.d.ts +10 -6
  18. package/dist/index.js +8 -9
  19. package/dist/index.js.map +1 -1
  20. package/dist/options.d.ts +69 -37
  21. package/dist/options.js +198 -31
  22. package/dist/options.js.map +1 -1
  23. package/dist/parse.d.ts +70 -0
  24. package/dist/parse.js +551 -0
  25. package/dist/parse.js.map +1 -0
  26. package/dist/program.d.ts +125 -0
  27. package/dist/program.js +337 -0
  28. package/dist/program.js.map +1 -0
  29. package/dist/remember.d.ts +71 -0
  30. package/dist/remember.js +216 -0
  31. package/dist/remember.js.map +1 -0
  32. package/dist/styling.d.ts +38 -9
  33. package/dist/styling.js +155 -75
  34. package/dist/styling.js.map +1 -1
  35. package/dist/terminal.d.ts +205 -0
  36. package/dist/terminal.js +152 -0
  37. package/dist/terminal.js.map +1 -0
  38. package/dist/tools.d.ts +35 -31
  39. package/dist/tools.js +68 -140
  40. package/dist/tools.js.map +1 -1
  41. package/dist/tui.d.ts +96 -0
  42. package/dist/tui.js +397 -0
  43. package/dist/tui.js.map +1 -0
  44. package/dist/tui_layout.d.ts +152 -0
  45. package/dist/tui_layout.js +554 -0
  46. package/dist/tui_layout.js.map +1 -0
  47. package/dist/tui_model.d.ts +149 -0
  48. package/dist/tui_model.js +666 -0
  49. package/dist/tui_model.js.map +1 -0
  50. package/package.json +18 -14
  51. package/.eslintrc.js +0 -24
  52. package/.idea/codeStyles/Project.xml +0 -364
  53. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  54. package/.idea/compiler.xml +0 -7
  55. package/.idea/encodings.xml +0 -6
  56. package/.idea/inspectionProfiles/Project_Default.xml +0 -12
  57. package/.idea/jsLibraryMappings.xml +0 -6
  58. package/.idea/modules.xml +0 -8
  59. package/.idea/prettier.xml +0 -8
  60. package/.idea/talented-args.iml +0 -11
  61. package/.idea/vcs.xml +0 -6
  62. package/.prettierrc.yaml +0 -4
  63. package/dist/definitions.d.ts +0 -70
  64. package/dist/definitions.js +0 -38
  65. package/dist/definitions.js.map +0 -1
  66. package/dist/main.d.ts +0 -33
  67. package/dist/main.js +0 -313
  68. package/dist/main.js.map +0 -1
  69. package/jest.config.js +0 -4
  70. package/tsconfig.json +0 -18
@@ -0,0 +1,149 @@
1
+ import { ICompiledCommand, ICompiledSchema } from './compile';
2
+ import { IInputSpec } from './descriptors';
3
+ import { IBinding } from './parse';
4
+ import { IRemembered } from './remember';
5
+ /**
6
+ * Terminal-independent editor state and key handling.
7
+ * Receive named keys and produce validated run, copy, or cancel outcomes.
8
+ */
9
+ /** Command list entry, including the optional entry for running without a command. */
10
+ export interface ITuiEntry {
11
+ readonly command: ICompiledCommand | null;
12
+ readonly label: string;
13
+ readonly summary: string;
14
+ /** Command details beyond its summary. Empty when the summary already covers them. */
15
+ readonly help: string;
16
+ }
17
+ /** Editable argument or flag in the options panel. */
18
+ export interface ITuiField {
19
+ readonly input: IInputSpec;
20
+ readonly name: string;
21
+ readonly kind: 'flag' | 'text';
22
+ /** Whether the field belongs to the selected command or to common options. */
23
+ readonly group: 'command' | 'common';
24
+ readonly required: boolean;
25
+ /** Negated flag name, such as `--no-color`, or `null` if none is available. */
26
+ readonly negation: string | null;
27
+ /** Short value hint, such as its type, requirement, or default. */
28
+ readonly hint: string;
29
+ /** Option description shown when the field is focused. */
30
+ readonly help: string;
31
+ }
32
+ export declare const TUI_REGIONS: readonly ["commands", "fields", "buttons"];
33
+ export type ITuiRegion = (typeof TUI_REGIONS)[number];
34
+ export declare const TUI_BUTTONS: readonly ["run", "copy", "cancel"];
35
+ export type ITuiButton = (typeof TUI_BUTTONS)[number];
36
+ /** Validated command selection and argument tokens. */
37
+ export interface ITuiCommandLine {
38
+ /** Selected command token, or `null` for running without a command. */
39
+ readonly command: string | null;
40
+ /** Argument tokens excluding the command token. */
41
+ readonly tokens: readonly string[];
42
+ }
43
+ export type ITuiOutcome = ({
44
+ readonly kind: 'run';
45
+ } & ITuiCommandLine) | ({
46
+ readonly kind: 'copy';
47
+ /** Complete command line with shell quoting and unmasked values, used for clipboard copying. */
48
+ readonly text: string;
49
+ /** Displayable command line with shell quoting and sensitive values masked. */
50
+ readonly shown: string;
51
+ /** Option names with values masked in `shown`. */
52
+ readonly masked: readonly string[];
53
+ } & ITuiCommandLine) | {
54
+ readonly kind: 'cancel';
55
+ };
56
+ /** Response to a key: no change, redraw, or close with a run, copy, or cancel outcome. */
57
+ export type ITuiReaction = 'none' | 'redraw' | ITuiOutcome;
58
+ export interface ITuiMessage {
59
+ readonly kind: 'error' | 'info';
60
+ readonly text: string;
61
+ }
62
+ /**
63
+ * Split a list field on whitespace, respecting single and double quotes and backslash escapes.
64
+ * Returns `null` for an unclosed quote. Does not perform shell expansion.
65
+ */
66
+ export declare function splitList(text: string): string[] | null;
67
+ /** Quote a value for a POSIX-style shell so it is read back unchanged. */
68
+ export declare function shellQuote(value: string): string;
69
+ export interface ITuiModelOptions {
70
+ /** Executable shown in the command preview. */
71
+ readonly executable: string;
72
+ /** An explicit command selection starts focus in its fields panel. */
73
+ readonly commandChosen: boolean;
74
+ /** Character used to mask sensitive values in command previews. */
75
+ readonly maskChar: string;
76
+ /** Saved or initial interactive state. Explicit command line values take precedence. */
77
+ readonly remembered?: IRemembered | null;
78
+ }
79
+ export declare class TuiModel {
80
+ private readonly schema;
81
+ private readonly options;
82
+ readonly entries: readonly ITuiEntry[];
83
+ /** Index of the selected command list entry. */
84
+ selected: number;
85
+ region: ITuiRegion;
86
+ fieldIndex: number;
87
+ button: ITuiButton;
88
+ message: ITuiMessage | null;
89
+ private drafts;
90
+ private errors;
91
+ private fieldsByEntry;
92
+ constructor(schema: ICompiledSchema, seed: IBinding, options: ITuiModelOptions);
93
+ get entry(): ITuiEntry;
94
+ /** Fields for the selected entry, with command options before unshared common options. */
95
+ get fields(): readonly ITuiField[];
96
+ get focusedField(): ITuiField | null;
97
+ /** Available navigation regions in Tab order. */
98
+ availableRegions(): ITuiRegion[];
99
+ /** Populate drafts from raw values for one scope. Returns whether values were supplied. */
100
+ private fillDrafts;
101
+ private draftsOf;
102
+ private draft;
103
+ /** Current field text, or an empty string when no value was entered. */
104
+ text(field: ITuiField): string;
105
+ /** Current flag draft: `true`, `false`, or `null` when unset. */
106
+ flag(field: ITuiField): boolean | null;
107
+ error(field: ITuiField): string | null;
108
+ /** Explanation for the focused command, field, or button. Empty when no extra explanation is needed. */
109
+ get help(): string;
110
+ /** Possible help texts for the selected entry, used to reserve a stable help area. */
111
+ get possibleHelp(): string[];
112
+ /** Update a field's draft and clear its validation error. An empty field removes the draft. */
113
+ setText(field: ITuiField, text: string): void;
114
+ private toggle;
115
+ /** Decode a text field to raw strings. Returns `null` for an unclosed list quote. */
116
+ private rawValues;
117
+ /**
118
+ * Validate a text field with its converter when focus leaves it.
119
+ * Skip empty fields until submission, when required inputs are checked.
120
+ */
121
+ private validateField;
122
+ /** Current command and raw argument tokens, excluding the executable. */
123
+ tokens(): string[];
124
+ /** Current command line for display, with shell quoting and sensitive values masked. */
125
+ preview(): string;
126
+ private commandLine;
127
+ /** Serialize the selected entry's arguments, excluding its command token. */
128
+ private argTokens;
129
+ /**
130
+ * Validate the current selection using normal parsing and conversion.
131
+ * On failure, mark invalid fields, focus the first one, and return `null`.
132
+ */
133
+ private check;
134
+ private run;
135
+ private copy;
136
+ private moveRegion;
137
+ private enterRegion;
138
+ private select;
139
+ private moveField;
140
+ /** Handle a key not consumed by a field, using terminal-kit key names. */
141
+ handleKey(key: string, isCharacter: boolean): ITuiReaction;
142
+ /**
143
+ * Whether Escape cancels rather than returning to the command list.
144
+ * It cancels from the command list or when there is no command list to return to.
145
+ */
146
+ get escapeLeaves(): boolean;
147
+ private press;
148
+ private dispatchKey;
149
+ }