deltegui / goshell

Small cli for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

goshell

Shell

Build Status BCH compliance

Small cli for Go

Example of use

package main

import "goshell"
import "fmt"

func echo(params ...string) error {
	fmt.Println(params)
	return nil
}

func hello(params ...string) error {
	fmt.Print("Hi")
	if len(params) >= 1 {
		fmt.Printf(" %s", params[0])
	}
	fmt.Printf("!\n")
	return nil
}

func main() {
	var (
		shell goshell.Shell
		notifyEnd chan bool
	)

	notifyEnd = make(chan bool)
	shell = goshell.NewDefaultShell()
	shell.RegistrerCommand("echo", echo)
	shell.RegistrerCommand("hello", hello)
	go goshell.Run(shell, notifyEnd)
	<-notifyEnd
}

About

Small cli for Go

License:GNU General Public License v3.0


Languages

Language:Go 100.0%