Skip to content

utilities for function-based command-line tools

License

Notifications You must be signed in to change notification settings

berquerant/fcli

Repository files navigation

fcli

Package fcli provides utilities for function-based command-line tools.

Usage

package main

import (
	"fmt"

	"github.com/berquerant/fcli"
)

func greet(name string) {
	fmt.Println("Hello,", name)
}

// bye prints Bye!
func bye() {
	fmt.Println("Bye!")
}

func main() {
	cli := fcli.NewCLI("do")
	_ = cli.Add(greet)
	_ = cli.Add(bye)
	_ = cli.Start()
}
❯ ./do
Error: not enough arguments
Usage: do {bye,greet}

❯ ./do greet -h
Usage of greet:
  -name string

❯ ./do greet -name world
Hello, world

❯ ./do bye -h
bye prints Bye!

❯ ./do bye
Bye!

Examples

examples

About

utilities for function-based command-line tools

Topics

Resources

License

Stars

Watchers

Forks

Languages