package cli import ( "fmt" "git.avsdev.uk/Go/job-search/internal/config" "git.avsdev.uk/Go/job-search/internal/fetcher" "git.avsdev.uk/Go/job-search/internal/skiprules" ) // SkipRulesOptions opens the rules file at sources.skip_rules_file and // returns the fetcher option that applies it, or none if no file is // configured. A missing or invalid file is an error, so a command doesn't // start without the rules it was given. func SkipRulesOptions(conf *config.JobSearchConfig) ([]fetcher.Option, error) { path := conf.Sources.SkipRulesFile if path == "" { return nil, nil } rulesFile, err := skiprules.Open(path) if err != nil { return nil, fmt.Errorf("sources.skip_rules_file: %w", err) } return []fetcher.Option{fetcher.WithSkipRules(rulesFile)}, nil }