qrcode

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &cli.Command{
	Name:    "qrcode",
	Usage:   "二维码生成、解析",
	Aliases: []string{"q"},
	Flags:   Flags,
	Action:  Action,
}
View Source
var Flags = []cli.Flag{
	&cli.StringFlag{
		Name:    "content",
		Aliases: []string{"c"},
		Usage:   "qrcode content",
	},
	&cli.StringFlag{
		Name:    "filename",
		Aliases: []string{"f"},
		Usage:   "qrcode filename",
		Action: func(context *cli.Context, s string) error {
			if _, err := os.Stat(s); os.IsNotExist(err) {
				return fmt.Errorf("文件 %s 不存在,请重新选择文件", s)
			}

			ext := filepath.Ext(s)
			if common.Identify(ext) == false {
				return fmt.Errorf(common.ExtError)
			}

			return nil
		},
	},
	&cli.StringFlag{
		Name:    "url",
		Aliases: []string{"u"},
		Usage:   "qrcode url",
		Action: func(context *cli.Context, s string) error {
			u, err := url.Parse(s)
			if err != nil {
				return fmt.Errorf("url %s 解析失败,请重新输入", s)
			}

			ext := filepath.Ext(u.Path)
			if common.Identify(ext) == false {
				return fmt.Errorf(common.ExtError)
			}

			return nil
		},
	},
}

Functions

func Action

func Action(c *cli.Context) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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