Пример #1
0
func main() {
	if checkSystemEnv("EDITOR") {
		var c int

		getopt.OptErr = 0
		for {
			if c = getopt.Getopt("r:h"); c == getopt.EOF {
				break
			}
			switch c {
			case 'r':
				args.read, _ = strconv.Atoi(getopt.OptArg)
			case 'h':
				usage()
				os.Exit(0)
			}
		}

		if checkFileExist(config.FilePath) {
			initSQL()
			article := getTitle(args.read)
			file := config.FilePath + hash(article)

			if checkFileExist(file) {
				openArticle(file)
			}
		} else {
			die("%s not found\n", config.FilePath)
		}
	} else {
		die("Your $EDITOR value is not set\n")
	}
}
Пример #2
0
func main() {
	args := Args{10}
	var c int

	getopt.OptErr = 0
	for {
		if c = getopt.Getopt("l:h"); c == getopt.EOF {
			break
		}
		switch c {
		case 'l':
			args.limit, _ = strconv.Atoi(getopt.OptArg)
		case 'h':
			usage()
			os.Exit(0)
		}
	}

	initSQL()
	showSQL(args.limit)
}