33A fully working, most feature-rich Vue.js terminal emulator. See the
44[ demo] ( https://ndabap.github.io/vue-command/ ) and check the demo
55[ source code] ( https://github.com/ndabAP/vue-command/blob/master/src/hosted/App.vue ) .
6+ In contrast to other terminal emulators, commands are not just
7+ mappings to external applications but are native components with
8+ injectable environment variables.
69
710## Features
811
@@ -26,16 +29,16 @@ $ npm install vue-command --save
2629## Usage
2730
2831Let's start with a dead simple example. We want to send "Hello world" to
29- ` Stdout ` when entering ` hello-world ` .
32+ ` stdout ` when entering ` hello-world ` .
3033
3134``` vue
3235<template>
3336 <vue-command :commands="commands" />
3437</template>
3538
3639<script>
37- import VueCommand, { createStdout } from " vue-command"
38- import " vue-command/dist/vue-command.css"
40+ import VueCommand, { createStdout } from ' vue-command'
41+ import ' vue-command/dist/vue-command.css'
3942
4043export default {
4144 components: {
@@ -44,7 +47,7 @@ export default {
4447
4548 data: () => ({
4649 commands: {
47- " hello-world" : () => createStdout(" Hello world" )
50+ ' hello-world' : () => createStdout(' Hello world' )
4851 }
4952 })
5053}
@@ -62,16 +65,16 @@ switch the terminal into fullscreen mode.
6265
6366``` vue
6467<template>
65- <div v-show=" terminal.isFullscreen" >
66- <textarea ref=" nano" @keyup.ctrl.x.exact=" exit" >
68+ <div v-show=' terminal.isFullscreen' >
69+ <textarea ref=' nano' @keyup.ctrl.x.exact=' exit' >
6770This is a nano text editor emulator! Press Ctrl + x to leave.</textarea
6871 >
6972 </div>
7073</template>
7174
7275<script>
7376export default {
74- inject: [" exit", " setFullscreen", " terminal" ],
77+ inject: [' exit', ' setFullscreen', ' terminal' ],
7578
7679 created() {
7780 this.setFullscreen(true)
@@ -95,22 +98,22 @@ Now the command has to return the component.
9598
9699``` vue
97100<template>
98- <vue-command :commands=" commands" />
101+ <vue-command :commands=' commands' />
99102</template>
100103
101104<script>
102- import VueCommand from " vue-command"
103- import " vue-command/dist/vue-command.css"
104- import NanoEditor from " @/components/NanoEditor.vue"
105+ import VueCommand from ' vue-command'
106+ import ' vue-command/dist/vue-command.css'
107+ import NanoEditor from ' @/components/NanoEditor.vue'
105108
106109export default {
107110 components: {
108- VueCommand,
111+ VueCommand
109112 },
110113
111114 data: () => ({
112115 commands: {
113- nano: () => NanoEditor,
116+ nano: () => NanoEditor
114117 }
115118 })
116119}
@@ -262,7 +265,7 @@ Library provides helper methods to render terminal related content.
262265Helper methods can be imported by name:
263266
264267``` js
265- import { createStdout , createQuery } from " vue-command" ;
268+ import { createStdout , createQuery } from ' vue-command'
266269```
267270
268271### Formatters
@@ -281,7 +284,7 @@ content as a list or table or something else.
281284Formatters can be imported by name:
282285
283286``` js
284- import { listFormatter } from " vue-command" ;
287+ import { listFormatter } from ' vue-command'
285288```
286289
287290## Provided
@@ -314,7 +317,7 @@ import { listFormatter } from "vue-command";
314317Provider can be injected into your component by name:
315318
316319``` js
317- inject: [" exit" , " terminal" ],
320+ inject: [" exit" , " terminal" ]
318321```
319322
320323## Exposed
@@ -352,18 +355,18 @@ is the only implemented signal for now. When the user presses
352355signal name and a callback:
353356
354357``` js
355- const signals = inject (" signals" );
358+ const signals = inject (' signals' )
356359const sigint = () => {
357360 // Tear down component
358361};
359- signals .on (" SIGINT" , sigint);
362+ signals .on (' SIGINT' , sigint)
360363```
361364
362365To unsubscribe from the signal, pass the same signal name and callback you used
363366to subscribe to the signal.
364367
365368``` js
366- signals .off (" SIGINT" , sigint);
369+ signals .off (' SIGINT' , sigint)
367370```
368371
369372The libraries query component makes usage of that and allows to cancel a query
0 commit comments