aboutsummaryrefslogtreecommitdiff
path: root/Sources
diff options
context:
space:
mode:
authorBen Beltran <ben@nsovocal.com>2016-11-12 23:40:17 -0600
committerBen Beltran <ben@nsovocal.com>2016-11-12 23:40:17 -0600
commit194a358163d7ac0a1f0ea61b1be3372c3532e1c5 (patch)
tree3f76b204d8f127152a6bde46e1be4f775510c8cc /Sources
parent026a2f69776d0a8c9e15e560bef4a8a01f510aa0 (diff)
Print the version with -v / --version
Diffstat (limited to 'Sources')
-rw-r--r--Sources/Lyricli.swift3
-rw-r--r--Sources/main.swift10
2 files changed, 12 insertions, 1 deletions
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()