]>
Commit | Line | Data |
---|---|---|
1 | // Source that reads track artist and name from the command line | |
2 | class ArgumentsSource: Source { | |
3 | ||
4 | // Returns a track based on the arguments. It assumes the track artist | |
5 | // will be the first argument, and the name will be the second, excluding | |
6 | // any flags. | |
7 | var currentTrack: Track? { | |
8 | ||
9 | if CommandLine.arguments.count >= 3 { | |
10 | // expected usage: $ ./lyricli <artist> <name> | |
11 | let trackName: String = CommandLine.arguments[2] | |
12 | let trackArtist: String = CommandLine.arguments[1] | |
13 | ||
14 | return Track(withName: trackName, andArtist: trackArtist) | |
15 | } | |
16 | return nil | |
17 | } | |
18 | } |