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