aboutsummaryrefslogtreecommitdiff
path: root/Sources/arguments_source.swift
diff options
context:
space:
mode:
Diffstat (limited to 'Sources/arguments_source.swift')
-rw-r--r--Sources/arguments_source.swift21
1 files changed, 11 insertions, 10 deletions
diff --git a/Sources/arguments_source.swift b/Sources/arguments_source.swift
index c07c952..9615318 100644
--- a/Sources/arguments_source.swift
+++ b/Sources/arguments_source.swift
@@ -1,17 +1,18 @@
-/// Source that deals with command line
+// Source that reads track artist and name from the command line
class ArgumentsSource: Source {
- public var currentTrack: Track? {
- get {
- if CommandLine.arguments.count >= 3 {
- // expected usage: $ ./lyricli <artist> <name>
+ // 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? {
- let trackName: String = CommandLine.arguments[2]
- let trackArtist: String = CommandLine.arguments[1]
+ 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
+ return Track(withName: trackName, andArtist: trackArtist)
}
+ return nil
}
}