Giter VIP home page Giter VIP logo

console-factory's Introduction

Console Factory ๐Ÿฆ†

This allows you to create a console with JLine to create commands for the terminal.

Using the Console Factory in your plugin

Maven

<dependencies>
 <dependency>
    <groupId>world.avionik</groupId>
    <artifactId>console-factory</artifactId>
    <version>1.0.1</version>
    <scope>provided</scope>
  </dependency>
</dependencies>

Gradle

dependencies {
    compileOnly 'world.avionik:console-factory:1.0.1'
}

How to create a new Console

You can implement the Console class in your Main class. That was actually all. Now you have the possibility to create commands. There is the ConsoleInput class. There you can set what the command should be called and what must be executed.

class MainConsoleClass : Console(
    ConsoleInput("first") { println("Second") }
)

What is a ConsoleInputExecutor

To have a "better code structure" there is the ConsoleInputExecutor. You can use it to create a class, implement this executor and write your command there. Here is an example:

class BirdExecutor : ConsoleInputExecutor {

    /**
     * This method is executed when a certain input is sent to the console.
     */
    override fun execute() {
        println("Im a bird")
    }

}

Once you have implemented this executor, you only need to integrate it into your main class that has implemented the Console interface. There you can register the executor with the ConsoleInput class. Here is another example:

class MainConsoleClass : Console(
    ConsoleInput("fly", executor = BirdExecutor())
)

// And this is how you can add aliases
class MainConsoleClass : Console(
    ConsoleInput("fly" "bird", executor = BirdExecutor())
)

console-factory's People

Contributors

niklasnieberler 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.