示例#1
0
func main() {
	flag.Parse()
	path := flag.Arg(0)

	f, err := os.Open(path)
	if err != nil {
		log.Fatal(err)
	}

	set, err := flash.Load(f)
	if err != nil {
		log.Fatal(err)
	}
	f.Close()

	words := map[string]int{}
	clean := true
	for _, c := range set.Cards {
		if line, ok := words[c.Front]; ok {
			log.Printf("line %v: duplicate of line %v", c.Line, line)
			clean = false
		} else {
			words[c.Front] = c.Line
		}
	}

	if clean {
		log.Printf("File %v checks out clean", path)
	}
}
示例#2
0
func main() {
	flag.Parse()
	if len(flag.Args()) != 1 {
		log.Fatal("Need 1 arg: <set-path>")
	}
	path := flag.Arg(0)

	f, err := os.Open(path)
	if err != nil {
		log.Fatal(err)
	}

	var set *flash.Set
	if set, err = flash.Load(f); err != nil {
		log.Fatal(err)
	}
	f.Close()

	writ := tabwriter.NewWriter(os.Stdout, 8, 4, 1, ' ', 0)

	fmt.Fprint(writ, "Front\tBack\tScore\n")
	fmt.Fprint(writ, "-------\t------\t------\n")
	for _, c := range set.Cards {
		fmt.Fprintf(writ, "%v\t%v\t%v\n", c.Front, c.Back, c.Score)
	}

	writ.Flush()
}
示例#3
0
func main() {
	log.SetFlags(log.LstdFlags | log.Lshortfile)
	flag.Parse()
	path := flag.Arg(0)

	f, err := os.Open(path)
	if err != nil {
		log.Fatal(err)
	}

	set, err := flash.Load(f)
	if err != nil {
		log.Fatal(err)
	}
	f.Close()

	for i := 0; i < *count; i++ {
		c := set.Next(*sw, *tw)
		ans := ""
		fmt.Printf("----------- Card %v -----------\n", i+1)
		if *bi {
			*back = rand.Float64() > 0.5
		}
		if *back {
			fmt.Printf(" Back: %v", c.Back)
			scanline()
			fmt.Printf("Front: %v\n Pass: "******"Front: %v", c.Front)
			scanline()
			fmt.Printf(" Back: %v\n Pass: "******"t", "true", "y", "yes":
			pass = true
		}
		c.AddView(pass)
	}
	save(set, path)
}