File tree 3 files changed +18
-4
lines changed
3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -206,6 +206,7 @@ content as a list or table or something else.
206
206
207
207
| Formatters |
208
208
| ---------------- |
209
+ | ` jsonFormatter ` |
209
210
| ` listFormatter ` |
210
211
| ` tableFormatter ` |
211
212
| ` textFormatter ` |
@@ -216,8 +217,6 @@ Formatters can be imported by name:
216
217
import { listFormatter } from " vue-command" ;
217
218
```
218
219
219
- Another possible formatter could be a ` jsonFormatter ` .
220
-
221
220
## Provided
222
221
223
222
| Provided |
Original file line number Diff line number Diff line change 15
15
<div class =" row mb-4" >
16
16
<div class =" col" >
17
17
<vue-command
18
+ v-model:dispatched-queries =" dispatchedQueries"
18
19
v-model:history =" history"
19
20
v-model:query =" query"
20
21
:commands =" commands"
21
22
:hide-bar =" hideBar"
22
23
:hide-prompt =" hidePrompt"
23
24
:invert =" invert"
24
25
:prompt =" prompt"
25
- help-text =" Type in help"
26
26
:options-resolver =" optionsResolver"
27
+ help-text =" Type in help"
27
28
show-help />
28
29
</div >
29
30
</div >
@@ -45,7 +46,9 @@ import {
45
46
createStdout ,
46
47
createQuery ,
47
48
listFormatter ,
48
- newDefaultHistory
49
+ newDefaultHistory ,
50
+ tableFormatter ,
51
+ jsonFormatter
49
52
} from ' @/library'
50
53
import NanoEditor from ' @/hosted/NanoEditor.vue'
51
54
import ChuckNorris from ' @/hosted/ChuckNorris.vue'
@@ -58,6 +61,7 @@ export default {
58
61
},
59
62
60
63
setup () {
64
+ const dispatchedQueries = ref (new Set ())
61
65
const hideBar = ref (false )
62
66
const hidePrompt = ref (false )
63
67
const history = ref (newDefaultHistory ())
@@ -72,6 +76,7 @@ export default {
72
76
case 1 :
73
77
setQuery (' cd home' )
74
78
break
79
+ // TODO Check last index instead of second
75
80
case 2 :
76
81
if (' home' .startsWith (parsedQuery[1 ]) && parsedQuery[1 ] !== ' home' ) {
77
82
setQuery (' cd home' )
@@ -114,10 +119,15 @@ export default {
114
119
return createStdout (listFormatter (... list))
115
120
},
116
121
122
+ json : () => {
123
+ return createStdout (jsonFormatter ({ test: 1 }))
124
+ },
125
+
117
126
nano : () => NanoEditor,
118
127
norris : () => ChuckNorris
119
128
},
120
129
130
+ dispatchedQueries,
121
131
hideBar,
122
132
hidePrompt,
123
133
history,
Original file line number Diff line number Diff line change @@ -110,6 +110,11 @@ export const listFormatter = (...lis) => {
110
110
// Returns a history with one query as first input
111
111
export const newDefaultHistory = ( ) => [ createQuery ( ) ]
112
112
113
+ // Formats the object as json
114
+ export const jsonFormatter = value => {
115
+ return h ( 'div' , JSON . stringify ( value , null , 2 ) )
116
+ }
117
+
113
118
// Formats the rows as HTML table
114
119
export const tableFormatter = rows => {
115
120
return ( ) => {
You can’t perform that action at this time.
0 commit comments