]> git.r.bdr.sh - rbdr/lyricli/blame - Sources/lyricli.swift
Update changelog
[rbdr/lyricli] / Sources / lyricli.swift
CommitLineData
d852b84e
BB
1// The main class, handles all the actions that the executable will call
2class Lyricli {
0b3e11a8 3
d852b84e 4 // Version of the application
0d4485a4 5 static var version = "0.1.0"
a968bff7 6
d852b84e
BB
7 // Flag that controls whether we should show the track artist and name before
8 // the lyrics
9 static var showTitle = false
10
11 // Obtains the name of the current track from a source, fetches the lyrics
12 // from an engine and prints them
13 static func printLyrics() {
4425e900
BB
14
15 let sourceManager = SourceManager()
16
17 if let currentTrack = sourceManager.currentTrack {
a968bff7
BB
18 let engine = LyricsEngine(withTrack: currentTrack)
19
20 if let lyrics = engine.lyrics {
21 if showTitle {
22 printTitle(currentTrack)
23 }
24
25 print(lyrics)
1263f62c 26 } else {
a968bff7
BB
27 print("Lyrics not found :(")
28 }
29
1263f62c 30 } else {
a968bff7 31 print("No Artist/Song could be found :(")
4425e900 32 }
0b3e11a8
BB
33 }
34
d852b84e
BB
35 // Print the currently available sources
36 static func printSources() {
0b3e11a8
BB
37 print("Listing Sources: Not yet implemented")
38 }
39
d852b84e
BB
40 // Runs the enable method of a source and writes the configuration to set it
41 // as enabled
42 static func enableSource(_ sourceName: String) {
0b3e11a8
BB
43 print("Enable source \(sourceName): Not yet implemented")
44 }
45
d852b84e
BB
46 // Remove a source from the enabled sources configuration
47 static func disableSource(_ sourceName: String) {
0b3e11a8
BB
48 print("Disable source \(sourceName): Not yet implemented")
49 }
50
d852b84e
BB
51 // Removes any configuration for a source, and disables it
52 static func resetSource(_ sourceName: String) {
0b3e11a8
BB
53 print("Reset source \(sourceName): Not yet implemented")
54 }
a968bff7 55
d852b84e 56 // Prints the track artist and name
a968bff7
BB
57 private static func printTitle(_ track: Track) {
58 print("\(track.artist) - \(track.name)")
59 }
194a3581 60}