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

Function SetConfig

client/hctx/hctx.go:310–334  ·  view source on GitHub ↗
(config *ClientConfig)

Source from the content-addressed store, hash-verified

308}
309
310func SetConfig(config *ClientConfig) error {
311 serializedConfig, err := json.Marshal(config)
312 if err != nil {
313 return fmt.Errorf("failed to serialize config: %w", err)
314 }
315 homedir, err := os.UserHomeDir()
316 if err != nil {
317 return fmt.Errorf("failed to retrieve homedir: %w", err)
318 }
319 err = MakeHishtoryDir()
320 if err != nil {
321 return err
322 }
323 configPath := path.Join(homedir, data.GetHishtoryPath(), data.CONFIG_PATH)
324 stagedConfigPath := configPath + ".tmp-" + uuid.Must(uuid.NewRandom()).String()
325 err = os.WriteFile(stagedConfigPath, serializedConfig, 0o644)
326 if err != nil {
327 return fmt.Errorf("failed to write config: %w", err)
328 }
329 err = os.Rename(stagedConfigPath, configPath)
330 if err != nil {
331 return fmt.Errorf("failed to replace config file with the updated version: %w", err)
332 }
333 return nil
334}
335
336func InitConfig() error {
337 homedir, err := os.UserHomeDir()

Callers 15

TestCtxConfigIsReferenceFunction · 0.92
ImportHistoryFunction · 0.92
EnableFunction · 0.92
DisableFunction · 0.92
handleUpgradedFeaturesFunction · 0.92
setupFunction · 0.92
switchToOnlineFunction · 0.92
switchToOfflineFunction · 0.92

Calls 3

GetHishtoryPathFunction · 0.92
MakeHishtoryDirFunction · 0.85
StringMethod · 0.80