Skip to content

jhalickman/linecommand

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Linecommand

Linecommand is a libraray that helps setup commands for interactive CLI applications. Linecommand is built ontop of Readline (github.com/chzyer/readline) and the API is modeled after Cobra (https://github.com/spf13/cobra).

##Usage To use linecommand:

  1. Simply create an instance of linecommand.App{}
  2. Add an instance of linecommand.Command{} for each command you want.
  3. Call app.Run()

Example:

package main

import (
	"fmt"
	"github.com/jhalickman/linecommand"
)

func main() {
	app := linecommand.App{}

	echoCommand := linecommand.Command{
		Use:   "echo",
		Short: "echo back what ever you say",
		Long:  "echo back what ever you say",
		Run: func(cmd *linecommand.Command, args string) {
			fmt.Println(args)
		},
	}

	app.DefaultRun = func(args string) {
		fmt.Printf("Oh noes that does not make sense. %s\n", args)
	}

	app.AddCommand(echoCommand)

	app.Run()
}

About

Command structure for interactive CLI applications

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages