diff options
| author | Ben Beltran <ben@nsovocal.com> | 2017-05-20 09:52:30 -0500 |
|---|---|---|
| committer | Ben Beltran <ben@nsovocal.com> | 2017-05-20 09:52:30 -0500 |
| commit | ee966aa755acd8eea53c982e43e13aef4f193984 (patch) | |
| tree | 5df111da5948ea198c5db1ca8f62e6c6ebe51178 /Sources/arguments_source.swift | |
| parent | bcd37f402a2586d051ac10a6a4982c8c226b2cce (diff) | |
| parent | 0d4485a445dd387235c141afca7764481eac0311 (diff) | |
Merge branch 'release/0.1.0'0.1.0
Diffstat (limited to 'Sources/arguments_source.swift')
| -rw-r--r-- | Sources/arguments_source.swift | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Sources/arguments_source.swift b/Sources/arguments_source.swift new file mode 100644 index 0000000..9615318 --- /dev/null +++ b/Sources/arguments_source.swift @@ -0,0 +1,18 @@ +// Source that reads track artist and name from the command line +class ArgumentsSource: Source { + + // 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? { + + 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 + } +} |