Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
func Parse()
Parse as flag.Parse with did you mean.
Example ¶
package main
import (
"bytes"
"flag"
"fmt"
"os"
"github.com/mashiike/didumean"
)
func main() {
var buf bytes.Buffer
flag.CommandLine = flag.NewFlagSet("example", flag.ContinueOnError)
flag.CommandLine.SetOutput(&buf)
os.Args = []string{"example", "-staing", "hoge"}
var (
val int
str string
on bool
)
flag.IntVar(&val, "value", 0, "value")
flag.StringVar(&str, "string", "", "string")
flag.BoolVar(&on, "on", false, "on")
didumean.Parse()
fmt.Println(buf.String())
}
Output: flag provided but not defined: -staing, did you mean -string Usage of example: -on on -string string string -value int value
Types ¶
type FlagSet ¶
FlagSet is *flag.FlagSet wrapper with did you mean function.
func NewFlagSet ¶
func NewFlagSet(name string, handling flag.ErrorHandling) *FlagSet
NewFlagSet create wraped FlagSet
Click to show internal directories.
Click to hide internal directories.