Code Monkey home page Code Monkey logo

vue-command's Introduction

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

Property Type Default Required Description
commands Object {} Yes Key-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-text String Type help No Sets the placeholder
help-timeout Number 4000 No Sets the placeholder timeout
hide-bar Boolean false No Hides the bar
hide-prompt Boolean false No Hides the prompt
intro String Fasten your seatbelts! No Sets the intro
prompt String ~neil@moon:# No Sets the prompt
show-help Boolean false No Shows the placeholder
show-intro Boolean false No Shows the intro
title String neil@moon: ~ No Sets the title
white-theme Boolean false No Enables the white theme
yargs-options Object {} No Sets 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

vue-command's People

Contributors

ndabap avatar dependabot-support avatar

Watchers

Sajibe Kanti avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.