charm

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2019 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

charm

minimalist CLI framework for Go

Documentation

Overview

Package charm is minimilast CLI framework inspired by cobra and urfave/cli.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoRun = errors.New("no run method")
View Source
var Help = &Spec{
	Name:  "help",
	Usage: "help [command]",
	Short: "display help for a command",
	Long: `
For help on the top-level command just type "help".
For help on a subcommand, type "help command" where command is the name of
the command.  For help on command nested further, type "help cmd1 cmd2" and
so forth.`,
	HiddenFlags: "v",
	New: func(parent Command, f *flag.FlagSet) (Command, error) {
		c := &HelpCommand{}
		f.BoolVar(&c.vflag, "v", false, "show hidden commands and flags")
		return c, nil
	},
}

Functions

This section is empty.

Types

type Command

type Command interface {
	Run([]string) error
}

type Constructor

type Constructor func(Command, *flag.FlagSet) (Command, error)

type HelpCommand

type HelpCommand struct {
	// contains filtered or unexported fields
}

func (*HelpCommand) Prepare

func (c *HelpCommand) Prepare(f *flag.FlagSet)

func (*HelpCommand) Run

func (c *HelpCommand) Run(args []string) error

type Spec

type Spec struct {
	Name          string
	Usage         string
	Short         string
	Long          string
	New           Constructor
	Hidden        bool
	HiddenFlags   string
	RedactedFlags string
	Empty         *Spec
	// contains filtered or unexported fields
}

func (*Spec) Add

func (c *Spec) Add(child *Spec)

func (*Spec) Exec

func (s *Spec) Exec(parent Command, args []string) error

func (*Spec) ExecRoot

func (s *Spec) ExecRoot(args []string) (Command, error)

ExecRoot execute this command spec, which must be a root spec. It returns the root command that was created.

func (*Spec) Prefix

func (c *Spec) Prefix() string

XXX

func (*Spec) Root

func (c *Spec) Root() *Spec

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址