]> git.r.bdr.sh - rbdr/lyricli/blame - Sources/arguments_source.swift
Update the version
[rbdr/lyricli] / Sources / arguments_source.swift
CommitLineData
d852b84e 1// Source that reads track artist and name from the command line
4425e900 2class ArgumentsSource: Source {
4425e900 3
d852b84e
BB
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? {
4425e900 8
d852b84e
BB
9 if CommandLine.arguments.count >= 3 {
10 // expected usage: $ ./lyricli <artist> <name>
1263f62c
BB
11 let trackName: String = CommandLine.arguments[2]
12 let trackArtist: String = CommandLine.arguments[1]
4425e900 13
1263f62c 14 return Track(withName: trackName, andArtist: trackArtist)
4425e900 15 }
1263f62c 16 return nil
4425e900
BB
17 }
18}