]> git.r.bdr.sh - rbdr/lyricli/blame_incremental - Sources/arguments_source.swift
Merge branch 'release/0.2.0'
[rbdr/lyricli] / Sources / arguments_source.swift
... / ...
CommitLineData
1// Source that reads track artist and name from the command line
2class 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}