Example #1
0
File: main.go Project: xlab/gitio
func main() {
	if len(codeOpt) > 0 && !forceOpt {
		taken, err := gitio.CheckTaken(codeOpt)
		if err != nil {
			fmt.Printf("error: %v\n", err)
			os.Exit(1)
		}
		if taken {
			fmt.Printf("warning: custom code \"%s\" has already been taken.\n", codeOpt)
			fmt.Println("tip: use the --force flag to suppress this check.")
			os.Exit(1)
		}
	}
	if u, err := url.Parse(longURL); err != nil {
		fmt.Printf("error: %v\n", err)
		os.Exit(1)
	} else if u.Scheme != "https" {
		fmt.Println("error: only HTTPS is supported, git.io will refuse HTTP links")
		os.Exit(1)
	}
	shortURL, err := gitio.Shorten(longURL, codeOpt)
	if err != nil {
		fmt.Printf("error: %v\n", err)
		os.Exit(1)
	}
	fmt.Println(shortURL)
}
Example #2
0
func main() {
	if len(codeOpt) > 0 && !forceOpt {
		taken, err := gitio.CheckTaken(codeOpt)
		if err != nil {
			fmt.Printf("error: %v\n", err)
			os.Exit(1)
		}
		if taken {
			fmt.Printf("warning: custom code \"%s\" has already been taken.\n", codeOpt)
			fmt.Println("tip: use the --force flag to suppress this check.")
			os.Exit(1)
		}
	}
	shortURL, err := gitio.Shorten(longURL, codeOpt)
	if err != nil {
		fmt.Printf("error: %v\n", err)
		os.Exit(1)
	}
	fmt.Println(shortURL)
	fmt.Printf("codeOPt is this", codeOpt)
}