inconshreveable / axiom

utilities to build production command line apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Axiom - Better CLI applications

An experimental set of tools to make it easier to build production command line applications.

import (
    "github.com/inconshreveable/axiom"
    "github.com/codegangsta/cli"
)

func main() {
    app := cli.NewApp()
    app.Name = "ctl"
    app.Usage = "control service"
    app.Commands = []cli.Command{
        {
            Name: "start",
            Action: func(c *cli.Context) {
                fmt.Println("starting service")
            },
        },
        {
            Name: "stop",
            Action: func(c *cli.Context) {
                fmt.Println("stopping service")
            },
        }
    }

    // Wrap all commands with:
    //  - flags to configure logging
    //  - custom crash handling
    //  - graceful handling of invocation from a GUI shell
    axiom.WrapApp(app, axiom.NewMousetrap(), axiom.NewLogged())

    // Use axiom to add version and update commands
    app.Commands = append(app.Commands,
        axiom.VersionCommand(),
        axiom.NewUpdater(equinoxAppId, updatePublicKey).Command(),
    )

    app.Run(os.Args)
}

About

utilities to build production command line apps


Languages

Language:Go 100.0%