From: Ben Beltran Date: Sat, 6 Oct 2012 05:21:33 +0000 (-0500) Subject: Implements the lrc executable X-Git-Url: https://git.r.bdr.sh/rbdr/lyricli.rb/commitdiff_plain/b9f550e97a60c4953fd1ae9374045110836764bd?hp=823e558b5cd2ec219d0fc7226c54f2ee7ad807d2 Implements the lrc executable --- diff --git a/bin/lrc b/bin/lrc index 52926e3..7bb2699 100755 --- a/bin/lrc +++ b/bin/lrc @@ -1,4 +1,49 @@ #!/usr/bin/env ruby -w +require 'optparse' require 'lyricli' + + +options = {} +OptionParser.new do |opts| + opts.banner = %{Usage: + lrc [options] + lrc artist song + lrc You must enable other sources for this + +Options: +} + + opts.on("-e", "--enable SOURCE", "Enable SOURCE") do |source| + puts "Enabling sources is not yet implemented" + exit + end + + opts.on("-l", "--list-sources", "List all available Sources") do + puts Lyricli.sources + exit + end + + opts.on("-d", "--disable SOURCE", "Disable SOURCE") do |source| + puts "Disabling sources is not yet implemented" + exit + end + + opts.on("-r", "--reset SOURCE", "Reset the configuration of SOURCE") do |source| + puts "Resetting sources is not yet implemented" + exit + end + + opts.on("-h", "--help", "Shows this message") do + puts opts + exit + end + + opts.on("-v", "--version", "Show version") do + puts Lyricli.version + exit + end +end.parse! + + puts Lyricli.lyrics diff --git a/lib/lyricli.rb b/lib/lyricli.rb index 22b604a..47db184 100755 --- a/lib/lyricli.rb +++ b/lib/lyricli.rb @@ -31,4 +31,25 @@ module Lyricli @lyricli = Lyricli.new @lyricli.get_lyrics end + + def self.version + Gem.loaded_specs["lyricli"].version + end + + def self.sources + source_manager = SourceManager.new + source_manager.available_sources.join(", ") + end + + def self.enable + + end + + def self.disable + + end + + def self.reset + + end end diff --git a/lib/lyricli/lyricli.rb b/lib/lyricli/lyricli.rb index 00aa184..06302f5 100644 --- a/lib/lyricli/lyricli.rb +++ b/lib/lyricli/lyricli.rb @@ -6,7 +6,7 @@ module Lyricli end def exit_with_error - abort "Usage: #{$0} artist song" + raise InvalidLyrics end def get_lyrics diff --git a/lib/lyricli/source_manager.rb b/lib/lyricli/source_manager.rb index 0e41ead..0bc81e5 100644 --- a/lib/lyricli/source_manager.rb +++ b/lib/lyricli/source_manager.rb @@ -54,5 +54,16 @@ module Lyricli end track end + + def available_sources + path_root = File.expand_path(File.dirname(__FILE__)) + sources = Dir[path_root+"/sources/*"].map{ |s| + s.split("/").last.gsub(/\.rb/, "") + } + + # Remove arguments (Hack?) We don't want anybody to touch tihs one. + sources.delete("arguments") + sources + end end end diff --git a/lyricli-0.0.1.gem b/lyricli-0.0.1.gem index ac16ca6..33a792a 100644 Binary files a/lyricli-0.0.1.gem and b/lyricli-0.0.1.gem differ diff --git a/lyricli.gemspec b/lyricli.gemspec index aec904f..41e6cf3 100644 --- a/lyricli.gemspec +++ b/lyricli.gemspec @@ -11,6 +11,8 @@ Gem::Specification.new do |s| s.files += Dir['[A-Z]*'] + Dir['spec/**/*'] s.files += Dir['lib/**/*.json'] + s.executables << 'lrc' + # Runtime Dependencies s.add_runtime_dependency 'nokogiri', '~> 1.5.5' s.add_runtime_dependency 'multi_json', '~> 1.3.6'