Example #1
0
File: hint.go Project: NJichev/jump
func hintCmd(args cli.Args, conf *config.Config) {
	var hints scoring.Entries

	term := args.CommandName()
	smart := args.Has("--smart")

	entries, err := conf.ReadEntries()
	if err != nil {
		cli.Exitf(1, "%s\n", err)
	}

	if len(term) == 0 {
		// We usually keep them reversely sort to optimize the fuzzy search.
		sort.Sort(sort.Reverse(entries))

		hints = hintSmartSelect(entries, term, smart)
	} else {
		fuzzyEntries := scoring.NewFuzzyEntries(entries, term)

		hints = hintSmartSelect(&fuzzyEntries.Entries, term, smart)
	}

	for _, entry := range hints {
		cli.Outf("%s\n", entry.Path)
	}
}