feat: add configuration flags and enhance config initialization

This commit is contained in:
krau
2025-12-19 13:49:13 +08:00
parent d3cc56c8e6
commit df64ec3069
4 changed files with 119 additions and 14 deletions

View File

@@ -34,7 +34,7 @@ func Run(cmd *cobra.Command, _ []string) {
})
ctx = log.WithContext(ctx, logger)
exitChan, err := initAll(ctx)
exitChan, err := initAll(ctx, cmd)
if err != nil {
logger.Fatal("Init failed", "error", err)
}
@@ -51,8 +51,9 @@ func Run(cmd *cobra.Command, _ []string) {
cleanCache()
}
func initAll(ctx context.Context) (<-chan struct{}, error) {
if err := config.Init(ctx); err != nil {
func initAll(ctx context.Context, cmd *cobra.Command) (<-chan struct{}, error) {
configFile := config.GetConfigFile(cmd)
if err := config.Init(ctx, configFile); err != nil {
return nil, fmt.Errorf("failed to load config: %w", err)
}
cache.Init()