Skip to content

Commit 63e6827

Browse files
committed
Remove old help; fix new help dyad
1 parent 1c5152b commit 63e6827

File tree

3 files changed

+22
-608
lines changed

3 files changed

+22
-608
lines changed

cmd/ari/input.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ import (
2020
type AutoCompleter struct {
2121
ariContext *ari.Context
2222
sqlKeywords []string
23-
goalKeywordsHelp map[string]string
2423
goalKeywordsKeys []string
2524
goalSyntaxAliases map[string]string
26-
goalSyntaxHelp map[string]string
2725
goalSyntaxKeys []string
2826
systemCommandsHelp map[string]string
2927
systemCommandsKeys []string
@@ -393,10 +391,8 @@ func (autoCompleter *AutoCompleter) sqlAutoCompleteFn() func(v [][]rune, line, c
393391

394392
func (autoCompleter *AutoCompleter) cacheGoalKeywords(goalContext *goal.Context) {
395393
goalKeywords := goalContext.Keywords(nil)
396-
goalKeywordsHelp := ari.GoalKeywordsHelp()
397394
sort.Strings(goalKeywords)
398395
autoCompleter.goalKeywordsKeys = goalKeywords
399-
autoCompleter.goalKeywordsHelp = goalKeywordsHelp
400396
}
401397

402398
func (autoCompleter *AutoCompleter) cacheGoalSyntax() {
@@ -408,7 +404,6 @@ func (autoCompleter *AutoCompleter) cacheGoalSyntax() {
408404
sort.Strings(keys)
409405
autoCompleter.goalSyntaxKeys = keys
410406
autoCompleter.goalSyntaxAliases = goalSyntax
411-
autoCompleter.goalSyntaxHelp = ari.GoalSyntaxHelp()
412407
}
413408

414409
func (autoCompleter *AutoCompleter) cacheSQL() {

context.go

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,7 @@ func NewSQLDatabase(dataSourceName string) (*SQLDatabase, error) {
4747

4848
func NewHelp() map[string]map[string]string {
4949
defaultSQLHelp := "A SQL keyword"
50-
// defaultGoalHelp := "A Goal keyword"
51-
goalGlobalsHelp := GoalGlobalsHelp()
52-
goalKeywordsHelp := GoalKeywordsHelp()
53-
goalSyntaxHelp := GoalSyntaxHelp()
54-
goalHelp := make(map[string]string, len(goalGlobalsHelp)+len(goalKeywordsHelp)+len(goalSyntaxHelp))
55-
for k, v := range goalGlobalsHelp {
56-
goalHelp[k] = v
57-
}
58-
for k, v := range goalKeywordsHelp {
59-
goalHelp[k] = v
60-
}
61-
for k, v := range goalSyntaxHelp {
62-
goalHelp[k] = v
63-
}
50+
goalHelp := GoalKeywordsHelp()
6451
sqlKeywords := SQLKeywords()
6552
sqlHelp := make(map[string]string, len(sqlKeywords))
6653
for _, x := range sqlKeywords {
@@ -76,8 +63,19 @@ func NewHelp() map[string]map[string]string {
7663
func NewContext(dataSourceName string) (*Context, error) {
7764
ctx := Context{}
7865
helpDictionary := NewHelp()
79-
// TODO HERE IS WHERE WE Wrap() a function that closes over helpDictionary to provide lookups for user-added help strings
80-
help := Help{Dictionary: helpDictionary, Func: help.HelpFunc()}
66+
ariHelpFunc := func(s string) string {
67+
goalHelp, ok := helpDictionary["goal"]
68+
if !ok {
69+
panic(`Developer Error: Dictionary in Help must have a \"goal\" entry.`)
70+
}
71+
help, found := goalHelp[s]
72+
if found {
73+
return help
74+
}
75+
return ""
76+
}
77+
helpFunc := help.Wrap(ariHelpFunc, help.HelpFunc())
78+
help := Help{Dictionary: helpDictionary, Func: helpFunc}
8179
sqlDatabase, err := NewSQLDatabase(dataSourceName)
8280
if err != nil {
8381
return nil, err

0 commit comments

Comments
 (0)