Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content
/ kli Public

Tiny CLI building tools for go apps

License

Notifications You must be signed in to change notification settings

openware/kli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Simple CLI library. Dependency free.

Features

  • Nested Subcommands
  • Uses the standard library flag package
  • Auto-generated help
  • Custom banners
  • Hidden Subcommands
  • Default Subcommand
  • Dependency free

Example

package main

import (
   "fmt"
   "log"

	"github.com/layer-3/neodax/finex/pkg/kli"
)

func main() {

	// Create new cli
	cli := kli.NewCli("Flags", "A simple example", "v0.0.1")

	// Name
	name := "Anonymous"
	cli.StringFlag("name", "Your name", &name)

	// Define action for the command
	cli.Action(func() error {
		fmt.Printf("Hello %s!\n", name)
		return nil
	})

	if err := cli.Run(); err != nil {
		fmt.Printf("Error encountered: %v\n", err)
	}

}

Generated Help

$ flags --help
Flags v0.0.1 - A simple example

Flags:

  -help
        Get help on the 'flags' command.
  -name string
        Your name

About

Tiny CLI building tools for go apps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages