+
Skip to content

nxtgo/kli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kli

suckless, zero-dependency cli builder for go.

features

  • simple as fuck (and therefore easy to use)
  • no dependencies (std only)
  • commands are just functions
  • subcommands with flags

example

package main

import (
	"fmt"
	"os"

	"github.com/nxtgo/kli"
)

func main() {
	app := kli.App{
		Name:        "app",
		Description: "a minimal cli built with kli",
		Author:      "you",
		Version:     "1.0.0",
		Commands: []kli.Command{
			{
				Name:        "hello",
				Description: "say hello",
				Category:    "greetings",
				Run: func(_ []string) error {
					fmt.Println("hello, world!")
					return nil
				},
			},
			{
				Name:        "remove",
				Aliases:     []string{"rm"},
				Description: "remove something",
				Category:    "util",
				Run: func(args []string) error {
					fmt.Println("removing:", args)
					return nil
				},
			},
		},
	}

	if err := app.Run(os.Args[1:]); err != nil {
		os.Exit(1)
	}
}

usage

$ app -h 
app - a minimal cli built with kli
by you
version 1.0.0

greetings:
  hello           say hello

util:
  remove (rm)     remove something

license

CC0 1.0 (public domain) + ip waiver.

About

build better clis

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载