cmd

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2017 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CommitHash string
	BuildTime  string
	Tag        string
)
View Source
var Alias, Channel, Event string
View Source
var RootCmd = &cobra.Command{
	Use:   "bjk URL SHORTCODE",
	Short: "a URL Shortening service and corresponding command line tool",
	Long: `bjk is a URL shortening service that automatically appends
the appropriate tracking tags to a URL.  The command line tool can be
used to submit a new link using personalized values.`,
	Args: cobra.ExactArgs(2),
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println("url", args[0])

		fmt.Println("short_code", args[1])
		err := submit(args[0], args[1])
		if err != nil {
			fmt.Println("Error: ", err)
		}

	},
}

RootCmd represents the base command when called without any subcommands

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

Types

type Config

type Config struct {
	Alias   string `yaml:"alias"`
	Event   string `yaml:"event"`
	Channel string `yaml:"channel"`
}

type Database

type Database interface {
	Get(shortcode string) (string, error)
	Save(shortcode, url string) (string, error)
	List() ([]Response, error)
}

Database interface

type Response

type Response struct {
	URL       string `json:"url"`
	ShortCode string `json:"short_code"`
	Error     string `json:"error"`
}

type Submission

type Submission struct {
	URL       string `json:"url"`
	ShortCode string `json:"short_code"`
}

Jump to

Keyboard shortcuts

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