]> git.r.bdr.sh - rbdr/lyricli/blobdiff - Sources/source_manager.swift
Merge branch 'release/0.2.0'
[rbdr/lyricli] / Sources / source_manager.swift
index e55cc8b18ae19e1acc222b442c6be788b21ea09c..aaac6963dfacef66482e3a1f7f054eb0138b5010 100644 (file)
@@ -1,10 +1,13 @@
-/// Manages the different sources. Keeps track of them, lists and toggles
+// Collect and manage the available and enabled source
 class SourceManager {
 
+    // List of sources enabled for the crurent platform
     private var availableSources: [String: Source] = [
-        "arguments": ArgumentsSource()
+        "arguments": ArgumentsSource(),
+        "itunes": ItunesSource()
     ]
 
+    // Iterate over the sources until we find a track or run out of sources
     var currentTrack: Track? {
         for source in enabledSources {
             if let currentTrack = source.currentTrack {
@@ -15,6 +18,7 @@ class SourceManager {
         return nil
     }
 
+    // Return the list of enabled sources based on the configuration
     var enabledSources: [Source] {
 
         // Checks the config and returns an array of sources based on the
@@ -22,7 +26,7 @@ class SourceManager {
 
         var sources = [Source]()
 
-        if let sourceNames = Configuration.sharedInstance["enabled_sources"] as? [String] {
+        if let sourceNames = Configuration.shared["enabled_sources"] as? [String] {
             for sourceName in sourceNames {
                 if let source = availableSources[sourceName] {
                     sources.append(source)
@@ -33,15 +37,15 @@ class SourceManager {
         return sources
     }
 
+    // Given a source name, it will enable it and add it to the enabled sources config
     func enable(sourceName: String) {
     }
 
+    // Given a source name, it will remove it from the enabled sources config
     func disable(sourceName: String) {
     }
 
+    // Given a source name, it removes any stored configuration and disables it
     func reset(sourceName: String) {
     }
-
-    func getSources(sourceName: String) {
-    }
 }