summaryrefslogtreecommitdiff
path: root/Sources/lyricli.swift
blob: 91e0c5115882d5932f356eb4c215a8293982e8a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// The main class, handles all the actions that the executable will call
class Lyricli {

    // Version of the application
    static var version = "0.2.0"

    // Flag that controls whether we should show the track artist and name before
    // the lyrics
    static var showTitle = false

    // Obtains the name of the current track from a source, fetches the lyrics
    // from an engine and prints them
    static func printLyrics() {

        let sourceManager = SourceManager()

        if let currentTrack = sourceManager.currentTrack {
            let engine = LyricsEngine(withTrack: currentTrack)

            if let lyrics = engine.lyrics {
                if showTitle {
                    printTitle(currentTrack)
                }

                print(lyrics)
            } else {
                print("Lyrics not found :(")
            }

        } else {
            print("No Artist/Song could be found :(")
        }
    }

    // Print the currently available sources
    static func printSources() {
        print("Listing Sources: Not yet implemented")
    }

    // Runs the enable method of a source and writes the configuration to set it
    // as enabled
    static func enableSource(_ sourceName: String) {
        print("Enable source \(sourceName): Not yet implemented")
    }

    // Remove a source from the enabled sources configuration
    static func disableSource(_ sourceName: String) {
        print("Disable source \(sourceName): Not yet implemented")
    }

    // Removes any configuration for a source, and disables it
    static func resetSource(_ sourceName: String) {
        print("Reset source \(sourceName): Not yet implemented")
    }

    // Prints the track artist and name
    private static func printTitle(_ track: Track) {
        print("\(track.artist) - \(track.name)")
    }
}