mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-18 21:52:28 +03:00
4521008b72
* Initial impl of 'sq config set' * Verbose output for 'sq config get' * config/options: refining 'sq config get' * Refine 'sq config get': now prints defaults when --verbose * cli: 'sq config get option.key' implemented * cli: initial impl of 'sq config get --src' * cli: refine 'sq config get' * cli: 'sq config set --src' is implemented
40 lines
856 B
Go
40 lines
856 B
Go
package config
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
// Store saves and loads config.
|
|
type Store interface {
|
|
// Save writes config to the store.
|
|
Save(ctx context.Context, cfg *Config) error
|
|
|
|
// Load reads config from the store.
|
|
Load(ctx context.Context) (*Config, error)
|
|
|
|
// Location returns the location of the store, typically
|
|
// a file path.
|
|
Location() string
|
|
}
|
|
|
|
// DiscardStore implements Store but its Save method is no-op
|
|
// and Load always returns a new empty Config. Useful for testing.
|
|
type DiscardStore struct{}
|
|
|
|
var _ Store = (*DiscardStore)(nil)
|
|
|
|
// Load returns a new empty Config.
|
|
func (DiscardStore) Load(context.Context) (*Config, error) {
|
|
return New(), nil
|
|
}
|
|
|
|
// Save is no-op.
|
|
func (DiscardStore) Save(context.Context, *Config) error {
|
|
return nil
|
|
}
|
|
|
|
// Location returns /dev/null.
|
|
func (DiscardStore) Location() string {
|
|
return "/dev/null"
|
|
}
|