File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Expand file tree Collapse file tree 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.
206206
207207| Formatters |
208208| ---------------- |
209+ | ` jsonFormatter ` |
209210| ` listFormatter ` |
210211| ` tableFormatter ` |
211212| ` textFormatter ` |
@@ -216,8 +217,6 @@ Formatters can be imported by name:
216217import { listFormatter } from " vue-command" ;
217218```
218219
219- Another possible formatter could be a ` jsonFormatter ` .
220-
221220## Provided
222221
223222| Provided |
Original file line number Diff line number Diff line change 1515 <div class =" row mb-4" >
1616 <div class =" col" >
1717 <vue-command
18+ v-model:dispatched-queries =" dispatchedQueries"
1819 v-model:history =" history"
1920 v-model:query =" query"
2021 :commands =" commands"
2122 :hide-bar =" hideBar"
2223 :hide-prompt =" hidePrompt"
2324 :invert =" invert"
2425 :prompt =" prompt"
25- help-text =" Type in help"
2626 :options-resolver =" optionsResolver"
27+ help-text =" Type in help"
2728 show-help />
2829 </div >
2930 </div >
@@ -45,7 +46,9 @@ import {
4546 createStdout ,
4647 createQuery ,
4748 listFormatter ,
48- newDefaultHistory
49+ newDefaultHistory ,
50+ tableFormatter ,
51+ jsonFormatter
4952} from ' @/library'
5053import NanoEditor from ' @/hosted/NanoEditor.vue'
5154import ChuckNorris from ' @/hosted/ChuckNorris.vue'
@@ -58,6 +61,7 @@ export default {
5861 },
5962
6063 setup () {
64+ const dispatchedQueries = ref (new Set ())
6165 const hideBar = ref (false )
6266 const hidePrompt = ref (false )
6367 const history = ref (newDefaultHistory ())
@@ -72,6 +76,7 @@ export default {
7276 case 1 :
7377 setQuery (' cd home' )
7478 break
79+ // TODO Check last index instead of second
7580 case 2 :
7681 if (' home' .startsWith (parsedQuery[1 ]) && parsedQuery[1 ] !== ' home' ) {
7782 setQuery (' cd home' )
@@ -114,10 +119,15 @@ export default {
114119 return createStdout (listFormatter (... list))
115120 },
116121
122+ json : () => {
123+ return createStdout (jsonFormatter ({ test: 1 }))
124+ },
125+
117126 nano : () => NanoEditor,
118127 norris : () => ChuckNorris
119128 },
120129
130+ dispatchedQueries,
121131 hideBar,
122132 hidePrompt,
123133 history,
Original file line number Diff line number Diff line change @@ -110,6 +110,11 @@ export const listFormatter = (...lis) => {
110110// Returns a history with one query as first input
111111export const newDefaultHistory = ( ) => [ createQuery ( ) ]
112112
113+ // Formats the object as json
114+ export const jsonFormatter = value => {
115+ return h ( 'div' , JSON . stringify ( value , null , 2 ) )
116+ }
117+
113118// Formats the rows as HTML table
114119export const tableFormatter = rows => {
115120 return ( ) => {
You can’t perform that action at this time.
0 commit comments