forked from Plemya-x/ALR
refactor: remove legacy code
This commit is contained in:
@@ -152,6 +152,13 @@ func (c *ALRConfig) Repos(ctx context.Context) []types.Repo {
|
||||
return c.cfg.Repos
|
||||
}
|
||||
|
||||
func (c *ALRConfig) SetRepos(ctx context.Context, repos []types.Repo) {
|
||||
c.cfgOnce.Do(func() {
|
||||
c.Load(ctx)
|
||||
})
|
||||
c.cfg.Repos = repos
|
||||
}
|
||||
|
||||
func (c *ALRConfig) IgnorePkgUpdates(ctx context.Context) []string {
|
||||
c.cfgOnce.Do(func() {
|
||||
c.Load(ctx)
|
||||
@@ -172,3 +179,17 @@ func (c *ALRConfig) PagerStyle(ctx context.Context) string {
|
||||
})
|
||||
return c.cfg.PagerStyle
|
||||
}
|
||||
|
||||
func (c *ALRConfig) AllowRunAsRoot(ctx context.Context) bool {
|
||||
c.cfgOnce.Do(func() {
|
||||
c.Load(ctx)
|
||||
})
|
||||
return c.cfg.Unsafe.AllowRunAsRoot
|
||||
}
|
||||
|
||||
func (c *ALRConfig) RootCmd(ctx context.Context) string {
|
||||
c.cfgOnce.Do(func() {
|
||||
c.Load(ctx)
|
||||
})
|
||||
return c.cfg.RootCmd
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
// ALR - Any Linux Repository
|
||||
// Copyright (C) 2025 Евгений Храмов
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/types"
|
||||
)
|
||||
|
||||
// Config returns a ALR configuration struct.
|
||||
// The first time it's called, it'll load the config from a file.
|
||||
// Subsequent calls will just return the same value.
|
||||
//
|
||||
// Deprecated: use struct method
|
||||
func Config(ctx context.Context) *types.Config {
|
||||
return GetInstance(ctx).cfg
|
||||
}
|
||||
|
||||
// =======================
|
||||
// FOR LEGACY ONLY
|
||||
// =======================
|
||||
|
||||
var (
|
||||
alrConfig *ALRConfig
|
||||
alrConfigOnce sync.Once
|
||||
)
|
||||
|
||||
// Deprecated: For legacy only
|
||||
func GetInstance(ctx context.Context) *ALRConfig {
|
||||
alrConfigOnce.Do(func() {
|
||||
alrConfig = New()
|
||||
alrConfig.Load(ctx)
|
||||
})
|
||||
|
||||
return alrConfig
|
||||
}
|
||||
@@ -19,10 +19,6 @@
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// Paths contains various paths used by ALR
|
||||
type Paths struct {
|
||||
ConfigDir string
|
||||
@@ -32,14 +28,3 @@ type Paths struct {
|
||||
PkgsDir string
|
||||
DBPath string
|
||||
}
|
||||
|
||||
// GetPaths returns a Paths struct.
|
||||
// The first time it's called, it'll generate the struct
|
||||
// using information from the system.
|
||||
// Subsequent calls will return the same value.
|
||||
//
|
||||
// Deprecated: use struct API
|
||||
func GetPaths(ctx context.Context) *Paths {
|
||||
alrConfig := GetInstance(ctx)
|
||||
return alrConfig.GetPaths(ctx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user