|
@@ -43,7 +43,7 @@ func Invalidate(config IConfig) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func ReadConfig[T IConfig](path string) (*T, error) {
|
|
|
+func Read[T IConfig](path string) (*T, error) {
|
|
|
var (
|
|
|
cfg = new(T)
|
|
|
fd []byte
|
|
@@ -58,6 +58,10 @@ func ReadConfig[T IConfig](path string) (*T, error) {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
+ if err = (*cfg).Invalidate(); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+
|
|
|
if err = Invalidate(*cfg); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
@@ -65,8 +69,8 @@ func ReadConfig[T IConfig](path string) (*T, error) {
|
|
|
return cfg, nil
|
|
|
}
|
|
|
|
|
|
-func LoadConfig[T IConfig](ctx *cli.Context, path cli.Path) error {
|
|
|
- cfg, err := ReadConfig[T](path)
|
|
|
+func Load[T IConfig](ctx *cli.Context, path cli.Path) error {
|
|
|
+ cfg, err := Read[T](path)
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("could not load config from: %s; %v", path, err)
|
|
|
}
|
|
@@ -79,7 +83,7 @@ func LoadConfig[T IConfig](ctx *cli.Context, path cli.Path) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func Config[T IConfig](ctx *cli.Context) *T {
|
|
|
+func Get[T IConfig](ctx *cli.Context) *T {
|
|
|
cfg, ok := ctx.App.Metadata["cli.config"].(*T)
|
|
|
if !ok {
|
|
|
return nil
|