5.1.4 • Published 6 years ago

@nathanfriend/vue-command v5.1.4

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

vue-command

A fully working Vue.js terminal emulator. See the demo.

Features

  • Parse arguments with yargs-parser
  • Search history (with /)
  • White/Dark theme support
  • Autocomplete (with )
  • Supports asynchronous commands

Installation

$ npm i vue-command --save

Properties

PropertyTypeDefaultRequiredDescription
commandsObject{}YesKey-value pairs where key is command and value is function with yargs arguments. Function should return either a String or a Promise that resolves to a String.
help-textStringType helpNoSets the placeholder
help-timeoutNumber4000NoSets the placeholder timeout
hide-barBooleanfalseNoHides the bar
hide-promptBooleanfalseNoHides the prompt
promptString~neil@moon:#NoSets the prompt
show-helpBooleanfalseNoShows the placeholder
titleStringneil@moon: ~NoSets the title
white-themeBooleanfalseNoEnables the white theme
yargs-optionsObject{}NoSets the yargs options

Usage

<template>
  <vue-command
    :yargs-options="{ alias: { color: ['colour'] } }"
    :commands="commands"
  />
</template>

<script>
import VueCommand from 'vue-command'
import 'vue-command/dist/vue-command.css'

export default {
  components: {
    VueCommand
  },

  data: () => ({
    commands: {
      // yargs arguments
      pokedex: ({ color, _ }) => {
        if (color && _[1] === 'pikachu') return 'yellow'

        return `Usage: pokedex pokemon [option]<br><br>

        Example: pokedex pikachu --color
        `
      }
    }
  })
}
</script>

<style lang="scss">
  .vue-command {
    .term {
      -webkit-border-radius: 8px;
      -moz-border-radius: 8px;
      border-radius: 8px;
    }

    .term-std {
      min-height: 300px;
      max-height: 300px;
      overflow-y: scroll;
    }
  }
</style>

Author

Julian Claus and contributors.

License

MIT