]> git.r.bdr.sh - rbdr/lyricli/commitdiff
Print the version with -v / --version
authorBen Beltran <redacted>
Sun, 13 Nov 2016 05:40:17 +0000 (23:40 -0600)
committerBen Beltran <redacted>
Sun, 13 Nov 2016 05:40:17 +0000 (23:40 -0600)
Sources/Lyricli.swift [new file with mode: 0644]
Sources/main.swift

diff --git a/Sources/Lyricli.swift b/Sources/Lyricli.swift
new file mode 100644 (file)
index 0000000..669dac9
--- /dev/null
@@ -0,0 +1,3 @@
+public class Lyricli {
+    public static var version = "0.0.0-feature/option-parsing"
+}
index 61f4f7154e11a8acbd658186d835a39da65274e3..b4d3ebfe4f11382d61ab1b93964160941f665cd4 100644 (file)
@@ -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()