hashid

package
v0.0.0-...-35fa527 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HashID = &cli.Command{
	Name:  "hashid",
	Usage: "encode ID to HashID",
	UsageText: `hashid [numbers...]
hashid 1988
hashid 1988 1990
hashid -d 17eok0yo
`,
	ArgsUsage: "encode [ids...]",
	Action: func(c *cli.Context) error {
		if c.NArg() == 0 {
			return errors.New("none id present")
		}

		for _, v := range c.Args().Slice() {
			if args.decode {
				id, err := decode(v)
				if err != nil {
					return err
				}

				print(id)
			} else {
				id, err := strconv.ParseInt(v, 10, 64)
				if err != nil {
					return err
				}

				hashed, err := encode(id)
				print(hashed)
			}
		}

		return nil
	},
	Flags: flags,
}

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