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