func main() {
	//arguments
	flag.Parse()
	if flag.NArg() < 1 {
		fmt.Fprintln(os.Stderr, os.ErrInvalid)
		return
	}
	urlStr := flag.Arg(0)

	//shortening url
	shortUrl, err := gitioapi.Encode(&gitioapi.Param{Url: urlStr})
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
	}
	fmt.Print(shortUrl)
}
// Run invokes the CLI with the given arguments.
func (cli *CLI) Run(args []string) int {
	var (
		c   string
		url string
	)

	// Define option flag parse
	flags := flag.NewFlagSet(Name, flag.ContinueOnError)
	flags.SetOutput(cli.errStream)

	flags.StringVar(&c, "c", "", "'code' parameter.")

	flVersion := flags.Bool("version", false, "Print version information and quit.")

	// Parse commandline flag
	if err := flags.Parse(args[1:]); err != nil {
		return ExitCodeError
	}

	// Show version
	if *flVersion {
		fmt.Fprintf(cli.errStream, "%s version %s\n", Name, Version)
		return ExitCodeOK
	}

	// Parse argument
	switch flags.NArg() {
	case 0:
		fmt.Fprintln(cli.errStream, os.ErrInvalid, "No GitHub URL")
		return ExitCodeError
	case 1:
		url = flags.Arg(0)
	default:
		fmt.Fprintln(cli.errStream, os.ErrInvalid, flags.Arg(1))
		return ExitCodeError
	}

	// shortening URL
	shortUrl, err := gitioapi.Encode(&gitioapi.Param{Url: url, Code: c})
	if err != nil {
		fmt.Fprintln(cli.errStream, err)
		return ExitCodeError
	}
	fmt.Fprint(cli.outStream, shortUrl)

	return ExitCodeOK
}
func ExampleEncode() {
	shortUrl, _ := gitioapi.Encode(&gitioapi.Param{Url: "https://github.com/technoweenie", Code: "t"})
	fmt.Print(shortUrl)
	// http://git.io/t
}