]> git.r.bdr.sh - rbdr/lyricli/blame - Sources/source_manager.swift
Improve comments in code
[rbdr/lyricli] / Sources / source_manager.swift
CommitLineData
d852b84e 1// Collect and manage the available and enabled source
a968bff7 2class SourceManager {
4425e900 3
d852b84e 4 // List of sources enabled for the crurent platform
4425e900
BB
5 private var availableSources: [String: Source] = [
6 "arguments": ArgumentsSource()
7 ]
8
d852b84e 9 // Iterate over the sources until we find a track or run out of sources
4425e900 10 var currentTrack: Track? {
1263f62c
BB
11 for source in enabledSources {
12 if let currentTrack = source.currentTrack {
13 return currentTrack
4425e900 14 }
4425e900 15 }
1263f62c
BB
16
17 return nil
4425e900
BB
18 }
19
d852b84e 20 // Return the list of enabled sources based on the configuration
4425e900
BB
21 var enabledSources: [Source] {
22
23 // Checks the config and returns an array of sources based on the
24 // enabled and available ones
25
1263f62c 26 var sources = [Source]()
4425e900 27
d852b84e 28 if let sourceNames = Configuration.shared["enabled_sources"] as? [String] {
1263f62c
BB
29 for sourceName in sourceNames {
30 if let source = availableSources[sourceName] {
31 sources.append(source)
4425e900
BB
32 }
33 }
4425e900 34 }
1263f62c
BB
35
36 return sources
4425e900
BB
37 }
38
d852b84e 39 // Given a source name, it will enable it and add it to the enabled sources config
4425e900
BB
40 func enable(sourceName: String) {
41 }
42
d852b84e 43 // Given a source name, it will remove it from the enabled sources config
4425e900
BB
44 func disable(sourceName: String) {
45 }
46
d852b84e 47 // Given a source name, it removes any stored configuration and disables it
4425e900
BB
48 func reset(sourceName: String) {
49 }
4425e900 50}