command

package
v0.0.0-...-5760210 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GenerateCommand = cli.Command{
		Name:  "generate",
		Usage: "產生假名",
		Flags: []cli.Flag{
			cli.StringFlag{
				Name:  "amount",
				Value: "10",
				Usage: "產生數量",
			},
			cli.StringFlag{
				Name:  "gender",
				Usage: "性別,可用參數: male, female",
			},
			cli.StringFlag{
				Name:  "first-name-num",
				Value: "2",
				Usage: "名的數量, 0 為 1 ~ 2 的亂數,單名給 1 ,雙名給 2",
			},
			cli.BoolFlag{
				Name:  "first-name-only",
				Usage: "只產生名",
			},
		},
		Action: func(c *cli.Context) error {
			num, err := strconv.Atoi(c.String("amount"))

			if err != nil {
				return err
			}

			firstNameNum, err := strconv.Atoi(c.String("first-name-num"))

			if err != nil {
				return err
			}

			facade.GenerateFirstNameNum = firstNameNum
			facade.GenerateGender = c.String("gender")
			facade.GenerateFirstNameOnly = c.Bool("first-name-only")

			return facade.Generate(c.GlobalString("provider"), num, func(item string, index int) {
				fmt.Println(item)
			})
		},
	}
)
View Source
var (
	InitCommand = cli.Command{
		Name:  "init",
		Usage: "初始化名字倉庫",
		Action: func(c *cli.Context) error {
			err := provider.InitFileDefault(c.GlobalString("provider"))

			return err
		},
	}
)
View Source
var (
	QueryCommand = cli.Command{
		Name:  "query",
		Usage: "查詢字典",
		Action: func(c *cli.Context) error {
			str := c.Args().First()

			return facade.Query(str, func(item string) {
				fmt.Println(item)
			})
		},
	}
)
View Source
var (
	ServeCommand = cli.Command{
		Name:  "serve",
		Usage: "啟動伺服器",
		Action: func(c *cli.Context) error {
			return serve(c)
		},
	}
)
View Source
var (
	StatusCommand = cli.Command{
		Name:  "status",
		Usage: "狀態",
		Action: func(c *cli.Context) error {
			t, _ := provider.ParseFile(c.GlobalString("provider"))

			fmt.Println(t)

			return nil
		},
	}
)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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