]> git.r.bdr.sh - rbdr/lyricli/blob - Sources/arguments_source.swift
9615318d4037f63b000a8d6561648daa0a6075a9
[rbdr/lyricli] / Sources / arguments_source.swift
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 }