wapty: github.com/empijei/wapty/cli Index | Files

package cli

import "github.com/empijei/wapty/cli"


Package Files

cmd.go help.go init.go


var (
    //Version is taken by the build flags, represent current version as
    Version string

    //Commit is the output of `git rev-parse HEAD` at the moment of the build
    Commit string

    //Build contains info about the scope of the build and should either be Debug or Release
    Build string = "Debug"
var WaptyCommands []*Cmd

WaptyCommands is the list of all wapty commands available. Each command `cmd` is invoked via `wapty cmd`

func AddCommand Uses

func AddCommand(c *Cmd)

AddCommand allows packages to setup their own command. In order for them to be compiled, they must be imported by the main package with the "_" alias

func Init Uses

func Init()

Init is the first function executed. It prints the banner and sets the default command.

func Printbanner Uses

func Printbanner()

Printbanner prints the initial banner

type Cmd Uses

type Cmd struct {
    // Name is the name of the command. It's what comes after `wapty`.
    Name string

    // Run is the command entrypoint.
    Run func(...string)

    // UsageLine is the header of what's printed by flag.PrintDefaults.
    UsageLine string

    // Short is a one-line description of what the command does.
    Short string

    // Long is the detailed description of what the command does.
    Long string

    // Flag is the set of flags accepted by the command. This should be initialized in
    // the command's module's `init` function. The parsing of these flags is issued
    // by the main wapty entrypoint, so each command doesn't have to do it itself.
    Flag flag.FlagSet

Cmd is used by any package exposing a runnable command to gather information about command name, usage and flagset.

var DefaultCommand *Cmd

DefaultCommand is the prefixed command set at the beginning of execution

func FindCommand Uses

func FindCommand(name string) (command *Cmd, err error)

FindCommand takes a string and searches for a command whose name has that string as prefix. If more than 1 command name has that string as a prefix (and no command name equals that string), an error is returned. If no suitable command is found, an error is returned.

func (*Cmd) Usage Uses

func (c *Cmd) Usage()

Usage prints out the usage helper

Package cli imports 9 packages (graph) and is imported by 6 packages. Updated 2018-02-22. Refresh now. Tools for package owners.