Skip to content

zachlatta/sergeant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sergeant

Sergeant is an opinionated command-line application framework for Go.

Installation

$ go get github.com/zachlatta/sergeant/sergeant

Getting Started

Sergeant is very easy to get started with. A basic application can be as simple as the following:

main.go

package main

import "github.com/zachlatta/sergeant/sergeant"

func main() {
  sergeant.ApplicationName = "helloworld"
  sergeant.ApplicationDescription = "helloworld prints `Hello World!` to the console."

  sergeant.Commands = []*sergeant.Command {
    cmdHello,
  }
  sergeant.Init()
}

hello.go

package main

import (
  "fmt"
  "github.com/zachlatta/sergeant/sergeant"
)

var cmdHello = &sergeant.Command {
  UsageLine: "hello",
  Short: "say hello to the world",
  Long: `
Hello greets the world with a friendly message.
`,
}

func init() {
  cmdHello.run = runHello
}

func runHello(cmd *sergeant.Command, args []string) {
  fmt.Println("Hello world!")
}

Running our application produces the following:

helloworld prints 'Hello World!' to the console.

Usage:

  helloworld command [arguments]

The commands are:

  hello       say hello to the world

Use "helloworld help [command]" for more information about a command.

For more usage examples, check out the examples folder.

About

An opinionated command-line application framework for Go.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages