]> git.r.bdr.sh - rbdr/lyricli/blobdiff - Sources/arguments_source.swift
Add the arguments source
[rbdr/lyricli] / Sources / arguments_source.swift
diff --git a/Sources/arguments_source.swift b/Sources/arguments_source.swift
new file mode 100644 (file)
index 0000000..c07c952
--- /dev/null
@@ -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 <artist> <name>
+
+                let trackName: String = CommandLine.arguments[2]
+                let trackArtist: String = CommandLine.arguments[1]
+
+                return Track(withName: trackName, andArtist: trackArtist)
+            }
+            return nil
+        }
+    }
+}