Skip to content

Commit 8421c68

Browse files
committed
chore!: fixes, features
1 parent 39073a8 commit 8421c68

25 files changed

+319
-155
lines changed

README.md

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Let's start with a dead simple example. We want to send "Hello world" to
3131
</template>
3232
3333
<script>
34-
import VueCommand, { createStdout } from "vue-command";
34+
import VueCommand, { createStdout, textFormatter } from "vue-command";
3535
import "vue-command/dist/vue-command.css";
3636
3737
export default {
@@ -41,7 +41,7 @@ export default {
4141
4242
data: () => ({
4343
commands: {
44-
"hello-world": () => createStdout("Hello world"),
44+
"hello-world": () => createStdout(textFormatter("Hello world")),
4545
},
4646
}),
4747
};
@@ -54,8 +54,8 @@ in many shells.
5454
We inject `terminal` to make sure the editor is only visible when the terminal
5555
is in fullscreen mode and also a function called `exit` to tell the terminal
5656
that the command has been finished when the user enters
57-
<kbd>Ctrl</kbd> + <kbd>x</kbd>. Furthermore, we use `setFullscreen` to switch
58-
the terminal into fullscreen mode.
57+
<kbd>Ctrl</kbd> + <kbd>x</kbd>. Furthermore, we use `setFullscreen` to
58+
switch the terminal into fullscreen mode.
5959

6060
```vue
6161
<template>
@@ -81,6 +81,7 @@ export default {
8181
</script>
8282
8383
<style scoped>
84+
div,
8485
textarea {
8586
height: 100%;
8687
}
@@ -124,8 +125,9 @@ required.
124125
| `cursor-position` | Cursor position | `Number` | `0` | No | Yes |
125126
| `dispatched-queries` | Non-empty dispatched queries, successful or not | `Set` | `new Set()` | No | Yes |
126127
| `event-resolver` | See [Event resolver](#Event-resolver) section | `Function` | See `newDefaultEventResolver` | No | No |
127-
| `help-text` | Query help | `String` | `''` | No | Yes |
128-
| `help-timeout` | Query help timeout | `Number` | `3500` | No | No |
128+
| `help-text` | Command help | `String` | `''` | No | Yes |
129+
| `help-timeout` | Command help timeout | `Number` | `3000` | No | No |
130+
| `hide-bar` | Hides the bar | `Boolean` | `false` | No | No |
129131
| `hide-prompt` | Hides the prompt | `Boolean` | `false` | No | No |
130132
| `history` | Terminal history | `Array` | `[]` | No | Yes |
131133
| `history-position` | Points to the latest dispatched query entry | `Number` | `0` | No | Yes |
@@ -174,27 +176,50 @@ the whole element, including the action buttons and its assigned CSS classes.
174176

175177
## Library
176178

179+
Library provides helper methods to render terminal related content.
180+
177181
| Function | Parameters | Description |
178182
| ----------------------------- | ------------------------------------------------------------------ | ------------------------------------- |
179183
| `createCommandNotFound` | `command, text = 'command not found', name = 'VueCommandNotFound'` | Creates a command not found component |
180184
| `createStdout` | `text, name = 'VueCommandStdout', innerHTML = false` | Creates a "stdout" component |
181185
| `createQuery` | | Creates a query component |
182186
| `defaultHistoryEventResolver` | `refs, eventProvider` | Returns the default history resolver |
183187
| `defaultParser` | `query` | Returns the default parser |
188+
| `listFormatter` | `...lis` | See [Formatters](#formatters) |
184189
| `newDefaultEventResolver` | | Returns a new default event resolver |
185190
| `newDefaultHistory` | | Returns a new default history |
191+
| `tableFormatter` | `rows` | See [Formatters](#formatters) |
192+
| `textFormatter` | `text, innerHtml = false` | See [Formatters](#formatters) |
186193

187194
Helper methods can be imported by name:
188195

189196
```js
190197
import { createStdout, createQuery } from "vue-command";
191198
```
192199

200+
### Formatters
201+
202+
`createStdout` requires a formatter as the first argument to format the content
203+
as a list or table or something else.
204+
205+
| Formatters |
206+
| ---------------- |
207+
| `listFormatter` |
208+
| `tableFormatter` |
209+
| `textFormatter` |
210+
211+
Formatters can be imported by name:
212+
213+
```js
214+
import { listFormatter } from "vue-command";
215+
```
216+
193217
## Provided
194218

195219
| Provided |
196220
| -------------------- |
197221
| `addDispatchedQuery` |
222+
| `appendToHistory` |
198223
| `dispatch` |
199224
| `decrementHistory` |
200225
| `exit` |
@@ -223,6 +248,7 @@ inject: ["exit", "terminal"],
223248
| Exposed |
224249
| -------------------- |
225250
| `addDispatchedQuery` |
251+
| `appendToHistory` |
226252
| `decrementHistory` |
227253
| `dispatch` |
228254
| `exit` |

docs/css/app.16bd4e83.css

Lines changed: 0 additions & 2 deletions
This file was deleted.

docs/css/app.16bd4e83.css.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/css/app.33ad189a.css

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/css/app.33ad189a.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)