aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md10
-rw-r--r--Sources/main.swift41
2 files changed, 49 insertions, 2 deletions
diff --git a/README.md b/README.md
index 6713a7d..71d7259 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,11 @@
-#Lyricli (lrc)
+# Lyricli (lrc)
A command line tool to show the lyrics of your current song
+
+## Building
+
+Run `swift build`
+
+## Running tests
+
+Run `swift test`
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()