yasmim

package module
v0.0.25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2020 License: MIT Imports: 7 Imported by: 0

README

Yasmim [WIP]

Build Status via Travis CI

yasmim is a golang library that helps to implement chain of responsibility design pattern.

Installation

If you are not using an IDE with go modules support, install it with go:

$ go get -u github.com/tsouza/yasmim

Import it into your code

import "github.com/tsouza/yasmim"

Quick Start

Register a command and run it

package main

import (
	"github.com/tsouza/yasmim"
	"github.com/tsouza/yasmim/pkg/command"
	"github.com/tsouza/yasmim/pkg/log"
)

const Name = "my_first_command"

func main() {
  	yasmim.Register(func(define command.Define) {
  		define.Command("my_first_command").
  			Handler(func(_ command.Runtime, _ *log.Logger, _, _ interface{}) error {
                // my_first_command Handler
            })
  	})

    _ = yasmim.New().Run("my_first_command", nil, nil)
}

License

Code and documentation released under The MIT License (MIT).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(builder command.Builder)

Types

type Yasmim

type Yasmim interface {
	Commands() map[string]*command.Command
	With(opts ...option.Option) Yasmim
	Run(command string, in, out interface{}) error
	Accept(visitor command.Visitor, commandName string) error
}

func New

func New() Yasmim

Directories

Path Synopsis
internal
pkg
log

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL