public class Lyricli {
public static var version = "0.0.0-feature/option-parsing"
+ public static var showTitle = false
+
public static func printLyrics() {
let sourceManager = SourceManager()
if let currentTrack = sourceManager.currentTrack {
- print(currentTrack.artist)
- print(currentTrack.name)
+
+ let engine = LyricsEngine(withTrack: currentTrack)
+
+ if let lyrics = engine.lyrics {
+ if showTitle {
+ printTitle(currentTrack)
+ }
+
+ print(lyrics)
+ }
+ else {
+ print("Lyrics not found :(")
+ }
+
}
else {
- print("Current track not found")
+ print("No Artist/Song could be found :(")
}
}
- public static func printTitle() {
- print("Getting Song Title: Not yet implemented")
- }
-
public static func printSources() {
print("Listing Sources: Not yet implemented")
}
public static func resetSource(_ sourceName: String) {
print("Reset source \(sourceName): Not yet implemented")
}
+
+ private static func printTitle(_ track: Track) {
+ print("\(track.artist) - \(track.name)")
+ }
}
--- /dev/null
+/// Looks for lyrics on the internet
+class LyricsEngine {
+
+ let track: Track
+
+ var lyrics: String? {
+ get {
+ if track.artist == "test" && track.name == "test" {
+ return "Doo doo doo"
+ }
+
+ return nil
+ }
+ }
+
+ init(withTrack targetTrack: Track) {
+
+ track = targetTrack
+ }
+}
/// Manages the different sources. Keeps track of them, lists and toggles
-public class SourceManager {
+class SourceManager {
private var availableSources: [String: Source] = [
"arguments": ArgumentsSource()
/// Contains the artist and name of a track
-public class Track {
- public let name: String
- public let artist: String
+class Track {
+ let name: String
+ let artist: String
init(withName trackName: String, andArtist trackArtist: String) {