shortencmd

package
v0.0.0-...-244131f Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ShortenCommandName = "shorten"
)

Variables

View Source
var Command = &cli.Command{
	Name:  ShortenCommandName,
	Usage: "Shorten a URL",
	Flags: shortenflgs.GetShortenFlags(),
	Action: func(ctx *cli.Context) error {
		serviceUrl, err := shortenflgs.GetShortenServiceUrl(ctx)
		if err != nil {
			return cli.Exit(err.Error(), 1)
		}

		ShortenCommandParams := &request.ShortenUrlRequest{
			Url:         ctx.String(shortenflgs.URLFlag),
			CustomShort: ctx.String(shortenflgs.ShortFlag),
			Expiration:  ctx.String(shortenflgs.TtlFlag),
		}

		resp, err := shortenURL(ShortenCommandParams, serviceUrl)
		if err != nil {
			return cli.Exit(err.Error(), 1)
		}

		fmt.Printf("%v\n", resp.String())
		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