Registered by Björn Tillenius

Package for creating command-oriented command line interfaces in Go.

The gocmdctrl package aims to make it easier to create command line
interfaces that have several commands. E.g.:

     example-cli import
     example-cli export

It includes a help command which prints information about the
available commands. A simple example that has a "help" and an "echo"
command:

    import "fmt"
    import "os"
    import "launchpad.net/gocmdtrl"

    func Echo(ctrl *gocmdctrl.CmdCtrl, args []string) int {
        for _, arg := range args {
            fmt.Fprintf(ctrl.Out, "%s ", arg)
        }
        fmt.Fprintf(ctrl.Out, "\n")
        return 0
    }

    ctrl := gocmdctrl.New(os.Args[0], os.Args[1:])
    ctrl.AddCommand(gocmdctrl.NewHelpCommand(), "help")
    ctrl.AddCommand(
        gocmdctrl.NewCommand(Echo, "Echo all arguments", "",
            []gocmdctrl.Arg{{"WORD", false, true}}),
        "hello")
    os.Exit(ctrl.Run())

A more complete example can be found in the example/ folder.

There are Out and Err io.Writer objects to use for writing information.
By default they are stdout and stderr, but they can be overridden to
make testing easier.

Project information

Maintainer:
Björn Tillenius
Driver:
Not yet selected
Licence:
Simplified BSD Licence

RDF metadata

View full history Series and milestones

trunk series is the current focus of development.

All code Code

Version control system:
Bazaar
Programming languages:
go,golang

All bugs Latest bugs reported

Get Involved

  • Report a bug
  • warning
    Ask a question
  • warning
    Help translate

Downloads

gocmdctrl does not have any download files registered with Launchpad.