@@ -11,7 +11,8 @@ A fully working, most feature-rich Vue.js terminal emulator. See the
11
11
- Supports fullscreen mode
12
12
- Customize the terminal with slots
13
13
- Provide your own parser (falls back to simple one)
14
- - Provide your own event resolver
14
+ - Provide your own event resolver to support keyboard
15
+ - Multiline support with ` \ `
15
16
- Autocompletion resolver (with <kbd >↹</kbd >)
16
17
- Browse history (with <kbd >↑</kbd >/<kbd >↓</kbd >)
17
18
- Search history (with <kbd >Ctrl</kbd > + <kbd >r</kbd >) (comming soon)
@@ -118,30 +119,30 @@ export default {
118
119
119
120
## Properties
120
121
121
- Some properties can be changed, therefore , adding the ` v-model ` directive is
122
- required.
123
-
124
- | Property | Description | Type | Default value | Required | ` v-model ` |
125
- | -------------------- | --------------------------------------------- | ---------- | ----------------------------- | -------- | --------- |
126
- | ` commands ` | See [ Commands] ( #commands ) | ` Object ` | ` {} ` | No | No |
127
- | ` cursor-position ` | Cursor position | ` Number ` | ` 0 ` | No | Yes |
128
- | ` dispatched-queries ` | Non-empty dispatched queries | ` Set ` | ` new Set() ` | No | Yes |
129
- | ` event-resolver ` | See [ Event resolver] ( #Event-resolver ) section | ` Function ` | See ` newDefaultEventResolver ` | No | No |
130
- | ` help-text ` | Command help | ` String ` | ` '' ` | No | Yes |
131
- | ` help-timeout ` | Command help timeout | ` Number ` | ` 3000 ` | No | No |
132
- | ` hide-bar ` | Hides the bar | ` Boolean ` | ` false ` | No | No |
133
- | ` hide-prompt ` | Hides the prompt | ` Boolean ` | ` false ` | No | No |
134
- | ` hide-title ` | Hides the title | ` Boolean ` | ` false ` | No | No |
135
- | ` history ` | Terminal history | ` Array ` | ` [] ` | No | Yes |
136
- | ` history-position ` | Points to the latest dispatched query entry | ` Number ` | ` 0 ` | No | Yes |
137
- | ` invert ` | Inverts the terminals colors | ` Boolean ` | ` false ` | No | No |
138
- | ` is-fullscreen ` | Terminal fullscreen mode | ` Boolean ` | ` false ` | No | Yes |
139
- | ` options-resolver ` | See [ Options resolver] ( #Options-resolver ) | ` Function ` | ` null ` | No | No |
140
- | ` parser ` | Query parser | ` Function ` | See ` defaultParser ` | No | No |
141
- | ` prompt ` | Terminal prompt | ` String ` | ` ~$ ` | No | No |
142
- | ` show-help ` | Show query help | ` Boolean ` | ` false ` | No | No |
143
- | ` title ` | Terminal title | ` String ` | ` ~$ ` | No | No |
144
- | ` query ` | Terminal query | ` String ` | ` '' ` | No | Yes |
122
+ Some properties can be mutated by the terminal. Therefore , adding the ` v-model `
123
+ directive is required.
124
+
125
+ | Property | Description | Type | Default value | Required | Two-way binding |
126
+ | -------------------- | ------------------------------------------- | ---------- | ------------------------- | -------- | ------ --------- |
127
+ | ` commands ` | See [ Commands] ( #commands ) | ` Object ` | ` {} ` | No | No |
128
+ | ` cursor-position ` | Cursor position | ` Number ` | ` 0 ` | No | Yes |
129
+ | ` dispatched-queries ` | Non-empty dispatched queries | ` Set ` | ` new Set() ` | No | Yes |
130
+ | ` event-resolver ` | See [ Event resolver] ( #Event-resolver ) | ` Function ` | ` newDefaultEventResolver ` | No | No |
131
+ | ` help-text ` | Command help | ` String ` | ` '' ` | No | Yes |
132
+ | ` help-timeout ` | Command help timeout | ` Number ` | ` 3000 ` | No | No |
133
+ | ` hide-bar ` | Hides the bar | ` Boolean ` | ` false ` | No | No |
134
+ | ` hide-prompt ` | Hides the prompt | ` Boolean ` | ` false ` | No | No |
135
+ | ` hide-title ` | Hides the title | ` Boolean ` | ` false ` | No | No |
136
+ | ` history ` | Terminal history | ` Array ` | ` [] ` | No | Yes |
137
+ | ` history-position ` | Points to the latest dispatched query entry | ` Number ` | ` 0 ` | No | Yes |
138
+ | ` invert ` | Inverts the terminals colors | ` Boolean ` | ` false ` | No | No |
139
+ | ` is-fullscreen ` | Terminal fullscreen mode | ` Boolean ` | ` false ` | No | Yes |
140
+ | ` options-resolver ` | See [ Options resolver] ( #Options-resolver ) | ` Function ` | ` null ` | No | No |
141
+ | ` parser ` | Query parser | ` Function ` | ` defaultParser ` | No | No |
142
+ | ` prompt ` | Terminal prompt | ` String ` | ` ~$ ` | No | No |
143
+ | ` show-help ` | Show query help | ` Boolean ` | ` false ` | No | No |
144
+ | ` title ` | Terminal title | ` String ` | ` ~$ ` | No | No |
145
+ | ` query ` | Terminal query | ` String ` | ` '' ` | No | Yes |
145
146
146
147
### Commands
147
148
@@ -150,6 +151,9 @@ and the value is a function that will be called with the parsed arguments. The
150
151
function can return a ` Promise ` and must return or resolve a Vue.js component.
151
152
To return strings or a new query, use one of the convenient helper methods.
152
153
154
+ Any component that is not the query component can inject the context. The
155
+ context includes the parsed and raw query as fields.
156
+
153
157
### Event resolver
154
158
155
159
It's possible to provide an array property ` eventResolver ` which is called when
@@ -197,7 +201,7 @@ Inside the bar, you can customize the buttons. Example:
197
201
### Title
198
202
199
203
Inside the bar, you can customize the title. If you use this slot, ` hideTitle `
200
- property has no effect. Example:
204
+ and ` title ` property have no effect. Example:
201
205
202
206
``` vue
203
207
<vue-command>
@@ -235,15 +239,15 @@ import { createStdout, createQuery } from "vue-command";
235
239
### Formatters
236
240
237
241
The first argument of ` createStdout ` can be either a primitive
238
- (` boolean ` , ` number ` or ` string ` ) or a formatter. A formatter formats the
242
+ (` Boolean ` , ` Number ` or ` String ` ) or a formatter. A formatter formats the
239
243
content as a list or table or something else.
240
244
241
- | Formatters |
242
- | ---------------- |
243
- | ` jsonFormatter ` |
244
- | ` listFormatter ` |
245
- | ` tableFormatter ` |
246
- | ` textFormatter ` |
245
+ | Function | Parameters |
246
+ | ---------------- | ------------------------- |
247
+ | ` jsonFormatter ` | ` value ` |
248
+ | ` listFormatter ` | ` ...lis ` |
249
+ | ` tableFormatter ` | ` rows ` |
250
+ | ` textFormatter ` | ` text, innerHtml = false ` |
247
251
248
252
Formatters can be imported by name:
249
253
@@ -253,28 +257,29 @@ import { listFormatter } from "vue-command";
253
257
254
258
## Provided
255
259
256
- | Provided |
257
- | -------------------- |
258
- | ` addDispatchedQuery ` |
259
- | ` appendToHistory ` |
260
- | ` dispatch ` |
261
- | ` decrementHistory ` |
262
- | ` exit ` |
263
- | ` helpText ` |
264
- | ` helpTimeout ` |
265
- | ` hidePrompt ` |
266
- | ` incrementHistory ` |
267
- | ` optionsResolver ` |
268
- | ` parser ` |
269
- | ` programs ` |
270
- | ` sendSignal ` |
271
- | ` setCursorPosition ` |
272
- | ` setFullscreen ` |
273
- | ` setHistoryPosition ` |
274
- | ` showHelp ` |
275
- | ` signals ` |
276
- | ` setQuery ` |
277
- | ` terminal ` |
260
+ | Identifier | Type | Parameters |
261
+ | -------------------- | ---------- | -------------------------------- |
262
+ | ` addDispatchedQuery ` | ` Function ` | ` dispatchedQuery ` |
263
+ | ` appendToHistory ` | ` Function ` | ` ...components ` |
264
+ | ` dispatch ` | ` Function ` | ` query ` |
265
+ | ` decrementHistory ` | ` Function ` | |
266
+ | ` exit ` | ` Function ` | |
267
+ | ` context ` | ` Object ` | |
268
+ | ` helpText ` | ` String ` | |
269
+ | ` helpTimeout ` | ` Number ` | |
270
+ | ` hidePrompt ` | ` Boolean ` | |
271
+ | ` incrementHistory ` | ` Function ` | |
272
+ | ` optionsResolver ` | ` Function ` | ` program, parsedQuery, setQuery ` |
273
+ | ` parser ` | ` Function ` | ` query ` |
274
+ | ` programs ` | ` Array ` | |
275
+ | ` sendSignal ` | ` Function ` | ` signal ` |
276
+ | ` setCursorPosition ` | ` Function ` | ` cursorPosition ` |
277
+ | ` setFullscreen ` | ` Function ` | ` isFullscreen ` |
278
+ | ` setHistoryPosition ` | ` Function ` | ` historyPosition ` |
279
+ | ` showHelp ` | ` Boolean ` | |
280
+ | ` signals ` | ` Object ` | |
281
+ | ` setQuery ` | ` Function ` | ` query ` |
282
+ | ` terminal ` | ` Object ` | |
278
283
279
284
Provider can be injected into your component by name:
280
285
@@ -284,22 +289,22 @@ inject: ["exit", "terminal"],
284
289
285
290
## Exposed
286
291
287
- | Exposed |
288
- | -------------------- |
289
- | ` addDispatchedQuery ` |
290
- | ` appendToHistory ` |
291
- | ` decrementHistory ` |
292
- | ` dispatch ` |
293
- | ` exit ` |
294
- | ` incrementHistory ` |
295
- | ` programs ` |
296
- | ` sendSignal ` |
297
- | ` setCursorPosition ` |
298
- | ` setFullscreen ` |
299
- | ` setHistoryPosition ` |
300
- | ` setQuery ` |
301
- | ` signals ` |
302
- | ` terminal ` |
292
+ | Identifier | Type | Parameters |
293
+ | -------------------- | ---------- | ----------------- |
294
+ | ` addDispatchedQuery ` | ` Function ` | ` dispatchedQuery ` |
295
+ | ` appendToHistory ` | ` Function ` | ` ...components ` |
296
+ | ` decrementHistory ` | ` Function ` | |
297
+ | ` dispatch ` | ` Function ` | ` query ` |
298
+ | ` exit ` | ` Function ` | |
299
+ | ` incrementHistory ` | ` Function ` | |
300
+ | ` programs ` | ` Function ` | |
301
+ | ` sendSignal ` | ` Function ` | ` signal ` |
302
+ | ` setCursorPosition ` | ` Function ` | ` cursorPosition ` |
303
+ | ` setFullscreen ` | ` Function ` | ` isFullscreen ` |
304
+ | ` setHistoryPosition ` | ` Function ` | ` historyPosition ` |
305
+ | ` setQuery ` | ` Function ` | ` query ` |
306
+ | ` signals ` | ` Object ` | |
307
+ | ` terminal ` | ` Function ` | |
303
308
304
309
## Events
305
310
@@ -318,7 +323,17 @@ signal name and a callback:
318
323
319
324
``` js
320
325
const signals = inject (" signals" );
321
- signals .on (" SIGINT" , () => console .debug (" SIGINT" ));
326
+ const sigint = () => {
327
+ // Tear down component
328
+ };
329
+ signals .on (" SIGINT" , sigint);
330
+ ```
331
+
332
+ To unsubscribe from the signal, pass the same signal name and callback you used
333
+ to subscribe to the signal.
334
+
335
+ ``` js
336
+ signals .off (" SIGINT" , sigint);
322
337
```
323
338
324
339
## Nice-to-haves
@@ -328,14 +343,12 @@ contribute please consult `CONTRIBUTING.md`.
328
343
329
344
- Draggable terminal
330
345
- More events (like query dispatched)
331
- - More terminal slots
332
- - Multi-line queries
333
- - Syntax highlighting
346
+ - More key combinations
334
347
335
348
## Browser support
336
349
337
- This library uses the ` ResizeObserver ` to track if the terminals height changes.
338
- You may need a pollyfill to support your target browser.
350
+ This library uses the ` MutationObserver ` to track if the terminal needs to
351
+ scroll to the bottom. You may need a pollyfill to support your target browser.
339
352
340
353
## Projects using vue-command
341
354
0 commit comments