gamesbrainiac / lemon

Citric command line tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lemon

Lemon is a simple package for building command line applications in Go.

Installation

Install Lemon using the "go get" command:

$ go get github.com/hjr265/lemon

The only dependency is the Go distribution itself.

Example

package main

import (
	"fmt"
	"strings"

	lmn "github.com/hjr265/lemon"
)

func handleEcho(c *lmn.Context) {
	fmt.Print(strings.Join(c.Args.Strings(0), " "))
	if !c.Flags.Bool("n") {
		fmt.Println()
	}
}

func main() {
	l := &lmn.Lemon{}
	l.NewAction("echo", "echos the string(s) to standard output").
		Flag("n", lmn.Bool, "suppress trailing newline").
		Arg(lmn.String, lmn.Repeat{true}).
		HandlerFunc(handleEcho)

	l.Run(nil)
}
$ go run main.go -h
Usage: main action [action-specific options]

  echo: echos the string(s) to standard output

$ go run main.go echo -h
Usage: main echo [flags] [arg0..]

  echo: echos the string(s) to standard output

  -n=false: suppress trailing newline

$ go run main.go echo Hello world!
Hello, world!

Documentation

Contributing

Contributions are welcome.

License

Lemon is available under the BSD (3-Clause) License

Inspiration

This project is inspired by the very existence of the awesome package github.com/codegangsta/cli and intuitiveness of github.com/gorilla/mux.

About

Citric command line tools

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Go 100.0%