From 026a2f69776d0a8c9e15e560bef4a8a01f510aa0 Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Sat, 12 Nov 2016 23:23:46 -0600 Subject: Add basic option parsing --- Sources/main.swift | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'Sources') diff --git a/Sources/main.swift b/Sources/main.swift index f7cf60e..61f4f71 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -1 +1,40 @@ -print("Hello, world!") +import CommandLineKit +import Foundation + +/// Sets up and returns a new options parser +/// +/// - Returns: A new OptionParser instance +func createParser() -> ([String:Option], CommandLineKit) { + + let parser = CommandLineKit() + var flags: [String:Option] = [:] + + flags["help"] = BoolOption(shortFlag: "h", longFlag: "help", helpMessage: "Prints a help message.") + + parser.addOptions(Array(flags.values)) + + return (flags, parser) +} + +func main() { + + let (flags, parser) = createParser() + + do { + try parser.parse() + } + catch { + parser.printUsage(error) + exit(EX_USAGE) + } + + if let helpFlag = flags["help"] as? BoolOption { + if helpFlag.value == true { + parser.printUsage() + exit(0) + } + } + +} + +main() -- cgit From 194a358163d7ac0a1f0ea61b1be3372c3532e1c5 Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Sat, 12 Nov 2016 23:40:17 -0600 Subject: Print the version with -v / --version --- Sources/Lyricli.swift | 3 +++ Sources/main.swift | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 Sources/Lyricli.swift (limited to 'Sources') diff --git a/Sources/Lyricli.swift b/Sources/Lyricli.swift new file mode 100644 index 0000000..669dac9 --- /dev/null +++ b/Sources/Lyricli.swift @@ -0,0 +1,3 @@ +public class Lyricli { + public static var version = "0.0.0-feature/option-parsing" +} diff --git a/Sources/main.swift b/Sources/main.swift index 61f4f71..b4d3ebf 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -3,13 +3,14 @@ import Foundation /// Sets up and returns a new options parser /// -/// - Returns: A new OptionParser instance +/// - Returns: A Dictionary of Options, and a new CommandLineKit instance func createParser() -> ([String:Option], CommandLineKit) { let parser = CommandLineKit() var flags: [String:Option] = [:] flags["help"] = BoolOption(shortFlag: "h", longFlag: "help", helpMessage: "Prints a help message.") + flags["version"] = BoolOption(shortFlag: "v", longFlag: "version", helpMessage: "Prints the version.") parser.addOptions(Array(flags.values)) @@ -35,6 +36,13 @@ func main() { } } + if let versionFlag = flags["version"] as? BoolOption { + if versionFlag.value == true { + print(Lyricli.version) + exit(0) + } + } + } main() -- cgit From 0b3e11a806e704fa373f0549fb3b6164d45c564a Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Sat, 12 Nov 2016 23:55:27 -0600 Subject: Add all options from original lyricli Options are mocked but pointing to correct place in library --- Sources/Lyricli.swift | 25 ++++++++++++++++++++++++ Sources/main.swift | 54 +++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 73 insertions(+), 6 deletions(-) (limited to 'Sources') diff --git a/Sources/Lyricli.swift b/Sources/Lyricli.swift index 669dac9..6c73e02 100644 --- a/Sources/Lyricli.swift +++ b/Sources/Lyricli.swift @@ -1,3 +1,28 @@ +/// The main Lyricli interface public class Lyricli { public static var version = "0.0.0-feature/option-parsing" + + public static func printLyrics() { + print("Getting Lyrics: Not yet implemented") + } + + public static func printTitle() { + print("Getting Song Title: Not yet implemented") + } + + public static func printSources() { + print("Listing Sources: Not yet implemented") + } + + public static func enableSource(_ sourceName: String) { + print("Enable source \(sourceName): Not yet implemented") + } + + public static func disableSource(_ sourceName: String) { + print("Disable source \(sourceName): Not yet implemented") + } + + public static func resetSource(_ sourceName: String) { + print("Reset source \(sourceName): Not yet implemented") + } } diff --git a/Sources/main.swift b/Sources/main.swift index b4d3ebf..47720ad 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -12,6 +12,13 @@ func createParser() -> ([String:Option], CommandLineKit) { flags["help"] = BoolOption(shortFlag: "h", longFlag: "help", helpMessage: "Prints a help message.") flags["version"] = BoolOption(shortFlag: "v", longFlag: "version", helpMessage: "Prints the version.") + flags["enableSource"] = StringOption(shortFlag: "e", longFlag: "enable-source", helpMessage: "Enables a source") + flags["disableSource"] = StringOption(shortFlag: "d", longFlag: "disable-source", helpMessage: "Disables a source") + flags["resetSource"] = StringOption(shortFlag: "r", longFlag: "reset-source", helpMessage: "Resets a source") + flags["listSources"] = BoolOption(shortFlag: "l", longFlag: "list-sources", helpMessage: "Lists all sources") + + flags["title"] = BoolOption(shortFlag: "t", longFlag: "title", helpMessage: "Shows title of song if true") + parser.addOptions(Array(flags.values)) return (flags, parser) @@ -31,18 +38,53 @@ func main() { if let helpFlag = flags["help"] as? BoolOption { if helpFlag.value == true { - parser.printUsage() - exit(0) - } + parser.printUsage() + exit(0) + } } if let versionFlag = flags["version"] as? BoolOption { if versionFlag.value == true { - print(Lyricli.version) - exit(0) - } + print(Lyricli.version) + exit(0) + } + } + + if let listSourcesFlag = flags["listSources"] as? BoolOption { + if listSourcesFlag.value == true { + Lyricli.printSources() + exit(0) + } + } + + if let enableSourceFlag = flags["enableSource"] as? StringOption { + if let source = enableSourceFlag.value { + Lyricli.enableSource(source) + exit(0) + } + } + + if let disableSourceFlag = flags["disableSource"] as? StringOption { + if let source = disableSourceFlag.value { + Lyricli.disableSource(source) + exit(0) + } + } + + if let resetSourceFlag = flags["resetSource"] as? StringOption { + if let source = resetSourceFlag.value { + Lyricli.resetSource(source) + exit(0) + } + } + + if let titleFlag = flags["title"] as? BoolOption { + if titleFlag.value == true { + Lyricli.printTitle() + } } + Lyricli.printLyrics() } main() -- cgit From 4425e9001e20e891dab7711644f83a1628788b47 Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Wed, 17 May 2017 23:06:25 -0500 Subject: Add the arguments source --- Sources/Lyricli.swift | 11 +++++++- Sources/arguments_source.swift | 17 ++++++++++++ Sources/configuration.swift | 62 ++++++++++++++++++++++++++++++++++++++++++ Sources/main.swift | 4 +++ Sources/source_manager.swift | 52 +++++++++++++++++++++++++++++++++++ Sources/source_protocol.swift | 3 ++ Sources/track.swift | 11 ++++++++ 7 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 Sources/arguments_source.swift create mode 100644 Sources/configuration.swift create mode 100644 Sources/source_manager.swift create mode 100644 Sources/source_protocol.swift create mode 100644 Sources/track.swift (limited to 'Sources') diff --git a/Sources/Lyricli.swift b/Sources/Lyricli.swift index 6c73e02..d55b500 100644 --- a/Sources/Lyricli.swift +++ b/Sources/Lyricli.swift @@ -3,7 +3,16 @@ public class Lyricli { public static var version = "0.0.0-feature/option-parsing" public static func printLyrics() { - print("Getting Lyrics: Not yet implemented") + + let sourceManager = SourceManager() + + if let currentTrack = sourceManager.currentTrack { + print(currentTrack.artist) + print(currentTrack.name) + } + else { + print("Current track not found") + } } public static func printTitle() { diff --git a/Sources/arguments_source.swift b/Sources/arguments_source.swift new file mode 100644 index 0000000..c07c952 --- /dev/null +++ b/Sources/arguments_source.swift @@ -0,0 +1,17 @@ +/// Source that deals with command line +class ArgumentsSource: Source { + public var currentTrack: Track? { + get { + if CommandLine.arguments.count >= 3 { + + // expected usage: $ ./lyricli + + let trackName: String = CommandLine.arguments[2] + let trackArtist: String = CommandLine.arguments[1] + + return Track(withName: trackName, andArtist: trackArtist) + } + return nil + } + } +} diff --git a/Sources/configuration.swift b/Sources/configuration.swift new file mode 100644 index 0000000..f5e4b0f --- /dev/null +++ b/Sources/configuration.swift @@ -0,0 +1,62 @@ +import Foundation + +/// Handles reading and writing the configuration +public class Configuration { + + let configurationPath = NSString(string: "~/.lyricli.conf").expandingTildeInPath + + // The defaults are added here + + private var configuration: [String: Any] = [ + "enabled_sources": ["arguments"], + "default": true + ] + + static let sharedInstance: Configuration = Configuration() + + private init() { + + // Read the config file and attempt toset any of the values. Otherwise + // Don't do anything. + // IMPROVEMENT: Enable a debug mode + + if let data = try? NSData(contentsOfFile: configurationPath) as Data { + if let parsedConfig = try? JSONSerialization.jsonObject(with: data) as! [String:Any] { + for (key, value) in parsedConfig { + + if key == "enabled_sources" { + configuration[key] = value as! [String] + } + else { + configuration[key] = value as! String + } + } + } + } + + writeConfiguration() + } + + private func writeConfiguration() { + + var error: NSError? + + if let outputStream = OutputStream(toFileAtPath: configurationPath, append: false) { + outputStream.open() + JSONSerialization.writeJSONObject(configuration, to: outputStream, options: [JSONSerialization.WritingOptions.prettyPrinted], error: &error) + outputStream.close() + } + } + + // Allow access as an object + subscript(index: String) -> Any? { + get { + return configuration[index] + } + + set(newValue) { + configuration[index] = newValue + writeConfiguration() + } + } +} diff --git a/Sources/main.swift b/Sources/main.swift index 47720ad..0ae48bc 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -84,6 +84,10 @@ func main() { } } + // Remove any flags so anyone after this gets the unprocessed values + let programName: [String] = [CommandLine.arguments[0]] + CommandLine.arguments = programName + parser.unparsedArguments + Lyricli.printLyrics() } diff --git a/Sources/source_manager.swift b/Sources/source_manager.swift new file mode 100644 index 0000000..d0af817 --- /dev/null +++ b/Sources/source_manager.swift @@ -0,0 +1,52 @@ +/// Manages the different sources. Keeps track of them, lists and toggles +public class SourceManager { + + private var availableSources: [String: Source] = [ + "arguments": ArgumentsSource() + ] + + var currentTrack: Track? { + get { + + for source in enabledSources { + if let currentTrack = source.currentTrack { + return currentTrack + } + } + + return nil + } + } + + var enabledSources: [Source] { + + // Checks the config and returns an array of sources based on the + // enabled and available ones + + get { + var sources = [Source]() + + if let sourceNames = Configuration.sharedInstance["enabled_sources"] as? [String]{ + for sourceName in sourceNames { + if let source = availableSources[sourceName] { + sources.append(source) + } + } + } + + return sources + } + } + + func enable(sourceName: String) { + } + + func disable(sourceName: String) { + } + + func reset(sourceName: String) { + } + + func getSources(sourceName: String) { + } +} diff --git a/Sources/source_protocol.swift b/Sources/source_protocol.swift new file mode 100644 index 0000000..ee9350c --- /dev/null +++ b/Sources/source_protocol.swift @@ -0,0 +1,3 @@ +protocol Source { + var currentTrack: Track? { get } +} diff --git a/Sources/track.swift b/Sources/track.swift new file mode 100644 index 0000000..efc09f4 --- /dev/null +++ b/Sources/track.swift @@ -0,0 +1,11 @@ +/// Contains the artist and name of a track +public class Track { + public let name: String + public let artist: String + + init(withName trackName: String, andArtist trackArtist: String) { + + name = trackName + artist = trackArtist + } +} -- cgit From a02972c1c6bfcc3248276ce43a9b0e0b6a9ba05e Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Wed, 17 May 2017 23:09:14 -0500 Subject: Rename because of case --- Sources/Lyricli.swift | 37 ------------------------------------- Sources/lor.swift | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 37 deletions(-) delete mode 100644 Sources/Lyricli.swift create mode 100644 Sources/lor.swift (limited to 'Sources') diff --git a/Sources/Lyricli.swift b/Sources/Lyricli.swift deleted file mode 100644 index d55b500..0000000 --- a/Sources/Lyricli.swift +++ /dev/null @@ -1,37 +0,0 @@ -/// The main Lyricli interface -public class Lyricli { - public static var version = "0.0.0-feature/option-parsing" - - public static func printLyrics() { - - let sourceManager = SourceManager() - - if let currentTrack = sourceManager.currentTrack { - print(currentTrack.artist) - print(currentTrack.name) - } - else { - print("Current track not 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 enableSource(_ sourceName: String) { - print("Enable source \(sourceName): Not yet implemented") - } - - public static func disableSource(_ sourceName: String) { - print("Disable source \(sourceName): Not yet implemented") - } - - public static func resetSource(_ sourceName: String) { - print("Reset source \(sourceName): Not yet implemented") - } -} diff --git a/Sources/lor.swift b/Sources/lor.swift new file mode 100644 index 0000000..d55b500 --- /dev/null +++ b/Sources/lor.swift @@ -0,0 +1,37 @@ +/// The main Lyricli interface +public class Lyricli { + public static var version = "0.0.0-feature/option-parsing" + + public static func printLyrics() { + + let sourceManager = SourceManager() + + if let currentTrack = sourceManager.currentTrack { + print(currentTrack.artist) + print(currentTrack.name) + } + else { + print("Current track not 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 enableSource(_ sourceName: String) { + print("Enable source \(sourceName): Not yet implemented") + } + + public static func disableSource(_ sourceName: String) { + print("Disable source \(sourceName): Not yet implemented") + } + + public static func resetSource(_ sourceName: String) { + print("Reset source \(sourceName): Not yet implemented") + } +} -- cgit From cadf28c5831b225abf9da650127659c0b0bf6e39 Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Wed, 17 May 2017 23:09:32 -0500 Subject: It's lowercase now! --- Sources/lor.swift | 37 ------------------------------------- Sources/lyricli.swift | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 37 deletions(-) delete mode 100644 Sources/lor.swift create mode 100644 Sources/lyricli.swift (limited to 'Sources') diff --git a/Sources/lor.swift b/Sources/lor.swift deleted file mode 100644 index d55b500..0000000 --- a/Sources/lor.swift +++ /dev/null @@ -1,37 +0,0 @@ -/// The main Lyricli interface -public class Lyricli { - public static var version = "0.0.0-feature/option-parsing" - - public static func printLyrics() { - - let sourceManager = SourceManager() - - if let currentTrack = sourceManager.currentTrack { - print(currentTrack.artist) - print(currentTrack.name) - } - else { - print("Current track not 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 enableSource(_ sourceName: String) { - print("Enable source \(sourceName): Not yet implemented") - } - - public static func disableSource(_ sourceName: String) { - print("Disable source \(sourceName): Not yet implemented") - } - - public static func resetSource(_ sourceName: String) { - print("Reset source \(sourceName): Not yet implemented") - } -} diff --git a/Sources/lyricli.swift b/Sources/lyricli.swift new file mode 100644 index 0000000..d55b500 --- /dev/null +++ b/Sources/lyricli.swift @@ -0,0 +1,37 @@ +/// The main Lyricli interface +public class Lyricli { + public static var version = "0.0.0-feature/option-parsing" + + public static func printLyrics() { + + let sourceManager = SourceManager() + + if let currentTrack = sourceManager.currentTrack { + print(currentTrack.artist) + print(currentTrack.name) + } + else { + print("Current track not 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 enableSource(_ sourceName: String) { + print("Enable source \(sourceName): Not yet implemented") + } + + public static func disableSource(_ sourceName: String) { + print("Disable source \(sourceName): Not yet implemented") + } + + public static func resetSource(_ sourceName: String) { + print("Reset source \(sourceName): Not yet implemented") + } +} -- cgit From a968bff7e21c9372deca5fce5921999b45d5d348 Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Wed, 17 May 2017 23:23:18 -0500 Subject: Simulate lyrics engine --- Sources/lyricli.swift | 28 +++++++++++++++++++++------- Sources/lyrics_engine.swift | 20 ++++++++++++++++++++ Sources/main.swift | 2 +- Sources/source_manager.swift | 2 +- Sources/track.swift | 6 +++--- 5 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 Sources/lyrics_engine.swift (limited to 'Sources') diff --git a/Sources/lyricli.swift b/Sources/lyricli.swift index d55b500..c44a7f4 100644 --- a/Sources/lyricli.swift +++ b/Sources/lyricli.swift @@ -2,23 +2,33 @@ 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") } @@ -34,4 +44,8 @@ public class Lyricli { public static func resetSource(_ sourceName: String) { print("Reset source \(sourceName): Not yet implemented") } + + private static func printTitle(_ track: Track) { + print("\(track.artist) - \(track.name)") + } } diff --git a/Sources/lyrics_engine.swift b/Sources/lyrics_engine.swift new file mode 100644 index 0000000..661ce86 --- /dev/null +++ b/Sources/lyrics_engine.swift @@ -0,0 +1,20 @@ +/// 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 + } +} diff --git a/Sources/main.swift b/Sources/main.swift index 0ae48bc..e4b2760 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -80,7 +80,7 @@ func main() { if let titleFlag = flags["title"] as? BoolOption { if titleFlag.value == true { - Lyricli.printTitle() + Lyricli.showTitle = true } } diff --git a/Sources/source_manager.swift b/Sources/source_manager.swift index d0af817..dd956ad 100644 --- a/Sources/source_manager.swift +++ b/Sources/source_manager.swift @@ -1,5 +1,5 @@ /// Manages the different sources. Keeps track of them, lists and toggles -public class SourceManager { +class SourceManager { private var availableSources: [String: Source] = [ "arguments": ArgumentsSource() diff --git a/Sources/track.swift b/Sources/track.swift index efc09f4..d2a9047 100644 --- a/Sources/track.swift +++ b/Sources/track.swift @@ -1,7 +1,7 @@ /// 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) { -- cgit From 85d0536f2e9a3d4596c01b263d76b2b8d9ba70ae Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Thu, 18 May 2017 21:54:32 -0500 Subject: Implement the lyrics engine --- Package.swift | 1 + Sources/lyrics_engine.swift | 130 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 127 insertions(+), 4 deletions(-) (limited to 'Sources') diff --git a/Package.swift b/Package.swift index 602b04b..5027708 100644 --- a/Package.swift +++ b/Package.swift @@ -4,5 +4,6 @@ let package = Package( name: "lyricli", dependencies: [ .Package(url: "https://github.com/rbdr/CommandLineKit", majorVersion: 4, minor: 0), + .Package(url: "https://github.com/IBM-Swift/swift-html-entities.git", majorVersion: 3, minor: 0) ] ) diff --git a/Sources/lyrics_engine.swift b/Sources/lyrics_engine.swift index 661ce86..d6b1985 100644 --- a/Sources/lyrics_engine.swift +++ b/Sources/lyrics_engine.swift @@ -1,15 +1,51 @@ +import Foundation +import HTMLEntities + /// Looks for lyrics on the internet class LyricsEngine { - let track: Track + private let apiURL = "https://lyrics.wikia.com/api.php?action=lyrics&func=getSong&fmt=realjson" + private let apiMethod = "GET" + private let lyricsMatcher = "class='lyricbox'>(.+) Void in + if let lyricsResult = lyricsResult { + lyrics = lyricsResult + requestFinished = true + asyncLock.signal() + } + }) + + while(!requestFinished) { + asyncLock.wait() + } + asyncLock.unlock() + } + } } - return nil + return lyrics } } @@ -17,4 +53,90 @@ class LyricsEngine { track = targetTrack } + + // Fetch the lyrics from the API and request / parse the page + + private func fetchLyricsFromAPI(withURL url: URL, completionHandler: @escaping (String?) -> Void) { + + var apiRequest = URLRequest(url: url) + apiRequest.httpMethod = "GET" + + let task = URLSession.shared.dataTask(with: apiRequest, completionHandler: {data, response, error -> Void in + + // If the response is parseable JSON, and has a url, we'll look for + // the lyrics in there + + if let data = data { + let jsonResponse = try? JSONSerialization.jsonObject(with: data) as! [String: Any] + if let jsonResponse = jsonResponse { + if let lyricsUrlString = jsonResponse["url"] as? String { + if let lyricsUrl = URL(string: lyricsUrlString) { + + // At this point we have a valid wiki url + self.fetchLyricsFromPage(withURL: lyricsUrl, completionHandler: completionHandler) + return + } + } + } + } + + completionHandler(nil) + }) + task.resume() + } + + // Fetch the lyrics from the page and parse the page + + private func fetchLyricsFromPage(withURL url: URL, completionHandler: @escaping (String?) -> Void) { + + var pageRequest = URLRequest(url: url) + pageRequest.httpMethod = "GET" + + let task = URLSession.shared.dataTask(with: pageRequest, completionHandler: {data, response, error -> Void in + + // If the response is parseable JSON, and has a url, we'll look for + // the lyrics in there + + if let data = data { + if let htmlBody = String(data: data, encoding: String.Encoding.utf8) { + self.parseHtmlBody(htmlBody, completionHandler: completionHandler) + return + } + } + + completionHandler(nil) + }) + task.resume() + } + + // Parses the wiki to obtain the lyrics + + private func parseHtmlBody(_ body: String, completionHandler: @escaping (String?) -> Void) { + + if let regex = try? NSRegularExpression(pattern: lyricsMatcher) { + let matches = regex.matches(in: body, range: NSRange(location: 0, length: body.characters.count)) + + for match in matches { + + let nsBody = body as NSString + let range = match.rangeAt(1) + let encodedLyrics = nsBody.substring(with: range) + + let decodedLyrics = decodeLyrics(encodedLyrics) + + completionHandler(decodedLyrics) + return + } + } + + completionHandler(nil) + } + + // Escapes the HTML entities + + private func decodeLyrics(_ lyrics: String) -> String { + + let unescapedLyrics = lyrics.htmlUnescape() + return unescapedLyrics.replacingOccurrences(of: "
", with: "\n") + } } -- cgit From 47f1de79ed1d0007dbba84dc3d511528c7fed3f0 Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Thu, 18 May 2017 22:44:25 -0500 Subject: Show the optional arguments --- Sources/main.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Sources') diff --git a/Sources/main.swift b/Sources/main.swift index e4b2760..42d4855 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -21,6 +21,21 @@ func createParser() -> ([String:Option], CommandLineKit) { parser.addOptions(Array(flags.values)) + parser.formatOutput = {parseString, type in + + var formattedString: String + + switch(type) { + case .About: + formattedString = "\(parseString) [ ]" + break + default: + formattedString = parseString + } + + return parser.defaultFormat(formattedString, type: type) + } + return (flags, parser) } -- cgit From 1263f62c5c6379f11e19eb184ffedf5889390b70 Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Thu, 18 May 2017 23:39:25 -0500 Subject: Fix linter warnings --- Sources/arguments_source.swift | 14 +++--- Sources/configuration.swift | 24 ++++++--- Sources/lyricli.swift | 6 +-- Sources/lyrics_engine.swift | 66 ++++++++++++------------ Sources/main.swift | 111 ++++++++++++++++++++++++++++------------- Sources/source_manager.swift | 29 +++++------ 6 files changed, 144 insertions(+), 106 deletions(-) (limited to 'Sources') diff --git a/Sources/arguments_source.swift b/Sources/arguments_source.swift index c07c952..d1bf4c6 100644 --- a/Sources/arguments_source.swift +++ b/Sources/arguments_source.swift @@ -1,17 +1,15 @@ /// Source that deals with command line class ArgumentsSource: Source { public var currentTrack: Track? { - get { - if CommandLine.arguments.count >= 3 { + if CommandLine.arguments.count >= 3 { - // expected usage: $ ./lyricli + // expected usage: $ ./lyricli - let trackName: String = CommandLine.arguments[2] - let trackArtist: String = CommandLine.arguments[1] + let trackName: String = CommandLine.arguments[2] + let trackArtist: String = CommandLine.arguments[1] - return Track(withName: trackName, andArtist: trackArtist) - } - return nil + return Track(withName: trackName, andArtist: trackArtist) } + return nil } } diff --git a/Sources/configuration.swift b/Sources/configuration.swift index f5e4b0f..bc21769 100644 --- a/Sources/configuration.swift +++ b/Sources/configuration.swift @@ -21,14 +21,19 @@ public class Configuration { // IMPROVEMENT: Enable a debug mode if let data = try? NSData(contentsOfFile: configurationPath) as Data { - if let parsedConfig = try? JSONSerialization.jsonObject(with: data) as! [String:Any] { - for (key, value) in parsedConfig { + if let parsedConfig = try? JSONSerialization.jsonObject(with: data) { + if let parsedConfig = parsedConfig as? [String: Any] { + for (key, value) in parsedConfig { - if key == "enabled_sources" { - configuration[key] = value as! [String] - } - else { - configuration[key] = value as! String + if key == "enabled_sources" { + if let value = value as? [String] { + configuration[key] = value + } + } else { + if let value = value as? String { + configuration[key] = value + } + } } } } @@ -43,7 +48,10 @@ public class Configuration { if let outputStream = OutputStream(toFileAtPath: configurationPath, append: false) { outputStream.open() - JSONSerialization.writeJSONObject(configuration, to: outputStream, options: [JSONSerialization.WritingOptions.prettyPrinted], error: &error) + JSONSerialization.writeJSONObject(configuration, + to: outputStream, + options: [JSONSerialization.WritingOptions.prettyPrinted], + error: &error) outputStream.close() } } diff --git a/Sources/lyricli.swift b/Sources/lyricli.swift index c44a7f4..5931ca1 100644 --- a/Sources/lyricli.swift +++ b/Sources/lyricli.swift @@ -18,13 +18,11 @@ public class Lyricli { } print(lyrics) - } - else { + } else { print("Lyrics not found :(") } - } - else { + } else { print("No Artist/Song could be found :(") } } diff --git a/Sources/lyrics_engine.swift b/Sources/lyrics_engine.swift index d6b1985..9741a2c 100644 --- a/Sources/lyrics_engine.swift +++ b/Sources/lyrics_engine.swift @@ -13,40 +13,37 @@ class LyricsEngine { // Fetches the lyrics and returns if found var lyrics: String? { - get { + var lyrics: String? - var lyrics: String? + if let artist = track.artist.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) { + if let name: String = track.name.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) { + if let url = URL(string: "\(apiURL)&artist=\(artist)&song=\(name)") { - if let artist = track.artist.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) { - if let name: String = track.name.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) { - if let url = URL(string: "\(apiURL)&artist=\(artist)&song=\(name)") { + // We'll lock until the async call is finished - // We'll lock until the async call is finished + var requestFinished = false + let asyncLock = NSCondition() + asyncLock.lock() - var requestFinished = false - let asyncLock = NSCondition() - asyncLock.lock() + // Call the API and unlock when you're done - // Call the API and unlock when you're done - - fetchLyricsFromAPI(withURL: url, completionHandler: {lyricsResult -> Void in - if let lyricsResult = lyricsResult { - lyrics = lyricsResult - requestFinished = true - asyncLock.signal() - } - }) - - while(!requestFinished) { - asyncLock.wait() + fetchLyricsFromAPI(withURL: url, completionHandler: {lyricsResult -> Void in + if let lyricsResult = lyricsResult { + lyrics = lyricsResult + requestFinished = true + asyncLock.signal() } - asyncLock.unlock() + }) + + while !requestFinished { + asyncLock.wait() } + asyncLock.unlock() } } - - return lyrics } + + return lyrics } init(withTrack targetTrack: Track) { @@ -61,20 +58,21 @@ class LyricsEngine { var apiRequest = URLRequest(url: url) apiRequest.httpMethod = "GET" - let task = URLSession.shared.dataTask(with: apiRequest, completionHandler: {data, response, error -> Void in + let task = URLSession.shared.dataTask(with: apiRequest, completionHandler: {data, _, _ -> Void in // If the response is parseable JSON, and has a url, we'll look for // the lyrics in there if let data = data { - let jsonResponse = try? JSONSerialization.jsonObject(with: data) as! [String: Any] - if let jsonResponse = jsonResponse { - if let lyricsUrlString = jsonResponse["url"] as? String { - if let lyricsUrl = URL(string: lyricsUrlString) { - - // At this point we have a valid wiki url - self.fetchLyricsFromPage(withURL: lyricsUrl, completionHandler: completionHandler) - return + if let jsonResponse = try? JSONSerialization.jsonObject(with: data) { + if let jsonResponse = jsonResponse as? [String: Any] { + if let lyricsUrlString = jsonResponse["url"] as? String { + if let lyricsUrl = URL(string: lyricsUrlString) { + + // At this point we have a valid wiki url + self.fetchLyricsFromPage(withURL: lyricsUrl, completionHandler: completionHandler) + return + } } } } @@ -92,7 +90,7 @@ class LyricsEngine { var pageRequest = URLRequest(url: url) pageRequest.httpMethod = "GET" - let task = URLSession.shared.dataTask(with: pageRequest, completionHandler: {data, response, error -> Void in + let task = URLSession.shared.dataTask(with: pageRequest, completionHandler: {data, _, _ -> Void in // If the response is parseable JSON, and has a url, we'll look for // the lyrics in there diff --git a/Sources/main.swift b/Sources/main.swift index 42d4855..5c39cb5 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -1,11 +1,43 @@ import CommandLineKit import Foundation +func main() { + let (flags, parser) = createParser() + + do { + try parser.parse() + } catch { + parser.printUsage(error) + exit(EX_USAGE) + } + + // Boolean Options + + checkHelpFlag(flags["help"], withParser: parser) + checkVersionFlag(flags["version"], withParser: parser) + checkListSourcesFlag(flags["listSources"], withParser: parser) + checkTitleFlag(flags["title"], withParser: parser) + + // String Options + + checkEnableSourceFlag(flags["enableSource"], withParser: parser) + checkDisableSourceFlag(flags["disableSource"], withParser: parser) + checkResetSourceFlag(flags["resetSource"], withParser: parser) + + // Remove any flags so anyone after this gets the unprocessed values + + let programName: [String] = [CommandLine.arguments[0]] + CommandLine.arguments = programName + parser.unparsedArguments + + // Run Lyricli + + Lyricli.printLyrics() +} + /// Sets up and returns a new options parser /// /// - Returns: A Dictionary of Options, and a new CommandLineKit instance -func createParser() -> ([String:Option], CommandLineKit) { - +private func createParser() -> ([String:Option], CommandLineKit) { let parser = CommandLineKit() var flags: [String:Option] = [:] @@ -25,7 +57,7 @@ func createParser() -> ([String:Option], CommandLineKit) { var formattedString: String - switch(type) { + switch type { case .About: formattedString = "\(parseString) [ ]" break @@ -39,71 +71,80 @@ func createParser() -> ([String:Option], CommandLineKit) { return (flags, parser) } -func main() { - - let (flags, parser) = createParser() +// Handle the Help flag - do { - try parser.parse() - } - catch { - parser.printUsage(error) - exit(EX_USAGE) - } - - if let helpFlag = flags["help"] as? BoolOption { - if helpFlag.value == true { +private func checkHelpFlag(_ flag: Option?, withParser parser: CommandLineKit) { + if let helpFlag = flag as? BoolOption { + if helpFlag.value { parser.printUsage() exit(0) } } +} - if let versionFlag = flags["version"] as? BoolOption { - if versionFlag.value == true { +// Handle the version flag + +private func checkVersionFlag(_ flag: Option?, withParser parser: CommandLineKit) { + if let versionFlag = flag as? BoolOption { + if versionFlag.value { print(Lyricli.version) exit(0) } } +} - if let listSourcesFlag = flags["listSources"] as? BoolOption { - if listSourcesFlag.value == true { +// Handle the list sources flag + +private func checkListSourcesFlag(_ flag: Option?, withParser parser: CommandLineKit) { + if let listSourcesFlag = flag as? BoolOption { + if listSourcesFlag.value { Lyricli.printSources() exit(0) } } +} + +// Handle the title flag + +private func checkTitleFlag(_ flag: Option?, withParser parser: CommandLineKit) { + if let titleFlag = flag as? BoolOption { + if titleFlag.value { + Lyricli.showTitle = true + } + } +} + +// Handle the enable source flag - if let enableSourceFlag = flags["enableSource"] as? StringOption { +private func checkEnableSourceFlag(_ flag: Option?, withParser parser: CommandLineKit) { + if let enableSourceFlag = flag as? StringOption { if let source = enableSourceFlag.value { Lyricli.enableSource(source) exit(0) } } +} + +// Handle the disable source flag - if let disableSourceFlag = flags["disableSource"] as? StringOption { +private func checkDisableSourceFlag(_ flag: Option?, withParser parser: CommandLineKit) { + if let disableSourceFlag = flag as? StringOption { if let source = disableSourceFlag.value { Lyricli.disableSource(source) exit(0) } } +} + +// Handle the reset source flag - if let resetSourceFlag = flags["resetSource"] as? StringOption { +private func checkResetSourceFlag(_ flag: Option?, withParser parser: CommandLineKit) { + if let resetSourceFlag = flag as? StringOption { if let source = resetSourceFlag.value { Lyricli.resetSource(source) exit(0) } } - - if let titleFlag = flags["title"] as? BoolOption { - if titleFlag.value == true { - Lyricli.showTitle = true - } - } - - // Remove any flags so anyone after this gets the unprocessed values - let programName: [String] = [CommandLine.arguments[0]] - CommandLine.arguments = programName + parser.unparsedArguments - - Lyricli.printLyrics() } main() diff --git a/Sources/source_manager.swift b/Sources/source_manager.swift index dd956ad..e55cc8b 100644 --- a/Sources/source_manager.swift +++ b/Sources/source_manager.swift @@ -6,16 +6,13 @@ class SourceManager { ] var currentTrack: Track? { - get { - - for source in enabledSources { - if let currentTrack = source.currentTrack { - return currentTrack - } + for source in enabledSources { + if let currentTrack = source.currentTrack { + return currentTrack } - - return nil } + + return nil } var enabledSources: [Source] { @@ -23,19 +20,17 @@ class SourceManager { // Checks the config and returns an array of sources based on the // enabled and available ones - get { - var sources = [Source]() + var sources = [Source]() - if let sourceNames = Configuration.sharedInstance["enabled_sources"] as? [String]{ - for sourceName in sourceNames { - if let source = availableSources[sourceName] { - sources.append(source) - } + if let sourceNames = Configuration.sharedInstance["enabled_sources"] as? [String] { + for sourceName in sourceNames { + if let source = availableSources[sourceName] { + sources.append(source) } } - - return sources } + + return sources } func enable(sourceName: String) { -- cgit From 74b4bbe9f35e7d29e0822a892b8498cab9b1801c Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Fri, 19 May 2017 00:19:14 -0500 Subject: Set the version to 0.0.0 --- Sources/lyricli.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Sources') diff --git a/Sources/lyricli.swift b/Sources/lyricli.swift index 5931ca1..10d9270 100644 --- a/Sources/lyricli.swift +++ b/Sources/lyricli.swift @@ -1,6 +1,6 @@ /// The main Lyricli interface public class Lyricli { - public static var version = "0.0.0-feature/option-parsing" + public static var version = "0.0.0" public static var showTitle = false -- cgit From d852b84edc24f1f1bbf4c34aa359447970e732b0 Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Sat, 20 May 2017 09:40:03 -0500 Subject: Improve comments in code --- Sources/arguments_source.swift | 11 +++++++---- Sources/configuration.swift | 26 +++++++++++++------------- Sources/lyricli.swift | 31 +++++++++++++++++++++---------- Sources/lyrics_engine.swift | 26 +++++++++++++++++--------- Sources/main.swift | 3 ++- Sources/source_manager.swift | 13 ++++++++----- Sources/source_protocol.swift | 2 ++ Sources/track.swift | 6 +++++- 8 files changed, 75 insertions(+), 43 deletions(-) (limited to 'Sources') diff --git a/Sources/arguments_source.swift b/Sources/arguments_source.swift index d1bf4c6..9615318 100644 --- a/Sources/arguments_source.swift +++ b/Sources/arguments_source.swift @@ -1,10 +1,13 @@ -/// Source that deals with command line +// Source that reads track artist and name from the command line class ArgumentsSource: Source { - public var currentTrack: Track? { - if CommandLine.arguments.count >= 3 { - // expected usage: $ ./lyricli + // Returns a track based on the arguments. It assumes the track artist + // will be the first argument, and the name will be the second, excluding + // any flags. + var currentTrack: Track? { + if CommandLine.arguments.count >= 3 { + // expected usage: $ ./lyricli let trackName: String = CommandLine.arguments[2] let trackArtist: String = CommandLine.arguments[1] diff --git a/Sources/configuration.swift b/Sources/configuration.swift index bc21769..f1a1ee1 100644 --- a/Sources/configuration.swift +++ b/Sources/configuration.swift @@ -1,24 +1,23 @@ import Foundation -/// Handles reading and writing the configuration -public class Configuration { - - let configurationPath = NSString(string: "~/.lyricli.conf").expandingTildeInPath - - // The defaults are added here +// Reads and writes the configuration. Config keys are accessed as a dictionary. +class Configuration { + // Location of the global configuration file + private let configurationPath = NSString(string: "~/.lyricli.conf").expandingTildeInPath + // Default options, will be automatically written to the global config if + // not found. private var configuration: [String: Any] = [ - "enabled_sources": ["arguments"], - "default": true + "enabled_sources": ["arguments"] ] - static let sharedInstance: Configuration = Configuration() + // The shared instance of the object + static let shared: Configuration = Configuration() private init() { - // Read the config file and attempt toset any of the values. Otherwise - // Don't do anything. - // IMPROVEMENT: Enable a debug mode + // Read the config file and attempt to set any of the values. Otherwise + // don't do anything. if let data = try? NSData(contentsOfFile: configurationPath) as Data { if let parsedConfig = try? JSONSerialization.jsonObject(with: data) { @@ -42,6 +41,7 @@ public class Configuration { writeConfiguration() } + // Write the configuration back to the file private func writeConfiguration() { var error: NSError? @@ -56,7 +56,7 @@ public class Configuration { } } - // Allow access as an object + // Allow access to the config properties as a dictionary subscript(index: String) -> Any? { get { return configuration[index] diff --git a/Sources/lyricli.swift b/Sources/lyricli.swift index 10d9270..e7d14b9 100644 --- a/Sources/lyricli.swift +++ b/Sources/lyricli.swift @@ -1,15 +1,20 @@ -/// The main Lyricli interface -public class Lyricli { - public static var version = "0.0.0" +// The main class, handles all the actions that the executable will call +class Lyricli { - public static var showTitle = false + // Version of the application + static var version = "0.0.0" - public static func printLyrics() { + // 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 { @@ -27,22 +32,28 @@ public class Lyricli { } } - public static func printSources() { + // Print the currently available sources + static func printSources() { print("Listing Sources: Not yet implemented") } - public static func enableSource(_ sourceName: String) { + // 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") } - public static func disableSource(_ sourceName: String) { + // Remove a source from the enabled sources configuration + static func disableSource(_ sourceName: String) { print("Disable source \(sourceName): Not yet implemented") } - public static func resetSource(_ sourceName: String) { + // 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)") } diff --git a/Sources/lyrics_engine.swift b/Sources/lyrics_engine.swift index 9741a2c..85e4735 100644 --- a/Sources/lyrics_engine.swift +++ b/Sources/lyrics_engine.swift @@ -1,20 +1,28 @@ import Foundation import HTMLEntities -/// Looks for lyrics on the internet +// Given a track, attempts to fetch the lyrics from lyricswiki class LyricsEngine { + // URL of the API endpoint to use private let apiURL = "https://lyrics.wikia.com/api.php?action=lyrics&func=getSong&fmt=realjson" + + // Method used to call the API private let apiMethod = "GET" + + // Regular expxression used to find the lyrics in the lyricswiki HTML private let lyricsMatcher = "class='lyricbox'>(.+) Void) { var apiRequest = URLRequest(url: url) @@ -83,8 +92,7 @@ class LyricsEngine { task.resume() } - // Fetch the lyrics from the page and parse the page - + // Fetch the lyrics from the page and send it to the parser private func fetchLyricsFromPage(withURL url: URL, completionHandler: @escaping (String?) -> Void) { var pageRequest = URLRequest(url: url) @@ -107,10 +115,11 @@ class LyricsEngine { task.resume() } - // Parses the wiki to obtain the lyrics - + // Parses the wiki to find the lyrics, decodes the lyrics object private func parseHtmlBody(_ body: String, completionHandler: @escaping (String?) -> Void) { + // Look for the lyrics lightbox + if let regex = try? NSRegularExpression(pattern: lyricsMatcher) { let matches = regex.matches(in: body, range: NSRange(location: 0, length: body.characters.count)) @@ -131,7 +140,6 @@ class LyricsEngine { } // Escapes the HTML entities - private func decodeLyrics(_ lyrics: String) -> String { let unescapedLyrics = lyrics.htmlUnescape() diff --git a/Sources/main.swift b/Sources/main.swift index 5c39cb5..9d46e92 100644 --- a/Sources/main.swift +++ b/Sources/main.swift @@ -1,7 +1,8 @@ import CommandLineKit import Foundation -func main() { +// Entry point of the application. This is the main executable +private func main() { let (flags, parser) = createParser() do { diff --git a/Sources/source_manager.swift b/Sources/source_manager.swift index e55cc8b..5ee1305 100644 --- a/Sources/source_manager.swift +++ b/Sources/source_manager.swift @@ -1,10 +1,12 @@ -/// 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() ] + // 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 +17,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 +25,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 +36,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) { - } } diff --git a/Sources/source_protocol.swift b/Sources/source_protocol.swift index ee9350c..0885994 100644 --- a/Sources/source_protocol.swift +++ b/Sources/source_protocol.swift @@ -1,3 +1,5 @@ +// All sources should comply with this protocol. The currentTrack computed +// property will return a track if the conditions are met protocol Source { var currentTrack: Track? { get } } diff --git a/Sources/track.swift b/Sources/track.swift index d2a9047..ead4359 100644 --- a/Sources/track.swift +++ b/Sources/track.swift @@ -1,6 +1,10 @@ -/// Contains the artist and name of a track +// Holds the name and artist of a track class Track { + + // The name of the track to search for let name: String + + // The name of the artist let artist: String init(withName trackName: String, andArtist trackArtist: String) { -- cgit From 0d4485a445dd387235c141afca7764481eac0311 Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Sat, 20 May 2017 09:50:16 -0500 Subject: Update the version --- CHANGELOG.md | 2 +- Makefile | 2 +- Sources/lyricli.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Sources') diff --git a/CHANGELOG.md b/CHANGELOG.md index 810e765..029adac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [Unreleased] +## 0.1.0 - 2017-05-20 ### Added - Documentation with Jazzy / SourceKitten - Apache License diff --git a/Makefile b/Makefile index 499e1d1..0f57bd9 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ document: build --author Lyricli \ --author_url https://github.com/lyricli-app \ --github_url https://github.com/lyricli-app/lyricli \ - --module-version 0.0.0 \ + --module-version 0.1.0 \ --module Lyricli \ clean: diff --git a/Sources/lyricli.swift b/Sources/lyricli.swift index e7d14b9..7d77a51 100644 --- a/Sources/lyricli.swift +++ b/Sources/lyricli.swift @@ -2,7 +2,7 @@ class Lyricli { // Version of the application - static var version = "0.0.0" + static var version = "0.1.0" // Flag that controls whether we should show the track artist and name before // the lyrics -- cgit