exit
end
+ opts.on("-t", "--title", "Shows the song title and artist") do
+ Lyricli.show_title
+ end
+
opts.on("-h", "--help", "Shows this message") do
puts opts
exit
# @return [String] the fetched lyrics
def self.lyrics
@lyricli = Lyricli.new
- @lyricli.get_lyrics
+ @lyricli.get_lyrics(@show_title)
end
# Returns the version of the library
def self.root
File.expand_path('../..',__FILE__)
end
+
+ # Sets the show_title instance variable so it requests the title
+ def self.show_title
+ @show_title = true
+ end
end
# LyricsEngine
#
# @return [String] the found lyrics, or a string indicating none were found
- def get_lyrics
+ def get_lyrics(show_title=false)
begin
set_current_track
engine = LyricsEngine.new(@current_track[:artist], @current_track[:song])
begin
- return engine.get_lyrics
+ lyrics_output = engine.get_lyrics
+
+ if show_title
+ lyrics_title = "#{@current_track[:artist]} - #{@current_track[:song]}"
+ lyrics_output = "#{lyrics_title}\n\n#{lyrics_output}"
+ end
+
+ return lyrics_output
rescue Exceptions::LyricsNotFoundError
return "Lyrics not found :("
end