]> git.r.bdr.sh - rbdr/lyricli/blame - Sources/lyricli/lyricli.swift
Removing build because no Scripting bridge :()
[rbdr/lyricli] / Sources / lyricli / 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
c71a08f5 5 static var version = "1.0.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 {
fdafe0d4
BB
18 printLyrics(currentTrack)
19 } else {
20 print("No Artist/Song could be found :(")
21 }
22 }
a968bff7 23
fdafe0d4
BB
24 // fetches the lyrics from an engine and prints them
25 static func printLyrics(_ currentTrack: Track) {
26 let engine = LyricsEngine(withTrack: currentTrack)
a968bff7 27
fdafe0d4
BB
28 if let lyrics = engine.lyrics {
29 if showTitle {
30 printTitle(currentTrack)
a968bff7
BB
31 }
32
fdafe0d4 33 print(lyrics)
1263f62c 34 } else {
fdafe0d4 35 print("Lyrics not found :(")
4425e900 36 }
0b3e11a8
BB
37 }
38
d852b84e
BB
39 // Print the currently available sources
40 static func printSources() {
0b3e11a8
BB
41 print("Listing Sources: Not yet implemented")
42 }
43
d852b84e
BB
44 // Runs the enable method of a source and writes the configuration to set it
45 // as enabled
46 static func enableSource(_ sourceName: String) {
0b3e11a8
BB
47 print("Enable source \(sourceName): Not yet implemented")
48 }
49
d852b84e
BB
50 // Remove a source from the enabled sources configuration
51 static func disableSource(_ sourceName: String) {
0b3e11a8
BB
52 print("Disable source \(sourceName): Not yet implemented")
53 }
54
d852b84e
BB
55 // Removes any configuration for a source, and disables it
56 static func resetSource(_ sourceName: String) {
0b3e11a8
BB
57 print("Reset source \(sourceName): Not yet implemented")
58 }
a968bff7 59
d852b84e 60 // Prints the track artist and name
a968bff7
BB
61 private static func printTitle(_ track: Track) {
62 print("\(track.artist) - \(track.name)")
63 }
194a3581 64}