MCPcopy
hub / github.com/ddworken/hishtory / MakeContext

Function MakeContext

client/hctx/hctx.go:128–146  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

126)
127
128func MakeContext() context.Context {
129 ctx := context.Background()
130 config, err := GetConfig()
131 if err != nil {
132 panic(fmt.Errorf("failed to retrieve config: %w", err))
133 }
134 ctx = context.WithValue(ctx, ConfigCtxKey, &config)
135 db, err := OpenLocalSqliteDb()
136 if err != nil {
137 panic(fmt.Errorf("failed to open local DB: %w", err))
138 }
139 ctx = context.WithValue(ctx, DbCtxKey, db)
140 homedir, err := os.UserHomeDir()
141 if err != nil {
142 panic(fmt.Errorf("failed to get homedir: %w", err))
143 }
144 ctx = context.WithValue(ctx, HomedirCtxKey, homedir)
145 return ctx
146}
147
148func GetConf(ctx context.Context) *ClientConfig {
149 v := ctx.Value(ConfigCtxKey)

Callers 15

setupTestTuiFunction · 0.92
testTui_scrollFunction · 0.92
testTui_escapingFunction · 0.92
testTui_defaultFilterFunction · 0.92
testTui_searchFunction · 0.92
testTui_aiFunction · 0.92
testControlRFunction · 0.92
TestCtxConfigIsReferenceFunction · 0.92
TestImportHistoryFunction · 0.92
BenchmarkImportFunction · 0.92

Calls 2

GetConfigFunction · 0.85
OpenLocalSqliteDbFunction · 0.85

Tested by 15

setupTestTuiFunction · 0.74
testTui_scrollFunction · 0.74
testTui_escapingFunction · 0.74
testTui_defaultFilterFunction · 0.74
testTui_searchFunction · 0.74
testTui_aiFunction · 0.74
testControlRFunction · 0.74
TestCtxConfigIsReferenceFunction · 0.74
TestImportHistoryFunction · 0.74
BenchmarkImportFunction · 0.74