]> git.r.bdr.sh - rbdr/lyricli.rb/commitdiff
Implements the lrc executable
authorBen Beltran <redacted>
Sat, 6 Oct 2012 05:21:33 +0000 (00:21 -0500)
committerBen Beltran <redacted>
Sat, 6 Oct 2012 05:21:33 +0000 (00:21 -0500)
bin/lrc
lib/lyricli.rb
lib/lyricli/lyricli.rb
lib/lyricli/source_manager.rb
lyricli-0.0.1.gem
lyricli.gemspec

diff --git a/bin/lrc b/bin/lrc
index 52926e393728382fd97bca0a2871e381cd69718a..7bb26999cee3aeda4ea4b88323a31858458e798a 100755 (executable)
--- a/bin/lrc
+++ b/bin/lrc
@@ -1,4 +1,49 @@
 #!/usr/bin/env ruby -w
 
 #!/usr/bin/env ruby -w
 
+require 'optparse'
 require 'lyricli'
 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
 puts Lyricli.lyrics
index 22b604a2daaf3ca3b140befb3053dd540be0e053..47db184bb23434fe4e1110fdc31c5e2fe133d95d 100755 (executable)
@@ -31,4 +31,25 @@ module Lyricli
     @lyricli = Lyricli.new
     @lyricli.get_lyrics
   end
     @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
 end
index 00aa184755e13124069577f72f55e497198f2def..06302f50948080335de90fd65303485826ba4d1f 100644 (file)
@@ -6,7 +6,7 @@ module Lyricli
     end
 
     def exit_with_error
     end
 
     def exit_with_error
-      abort "Usage: #{$0} artist song"
+      raise InvalidLyrics
     end
 
     def get_lyrics
     end
 
     def get_lyrics
index 0e41ead5e6ad2b66638c91345b896124f6ac4c23..0bc81e5f5b313c45c0904dc5cf8c943aa7ab3854 100644 (file)
@@ -54,5 +54,16 @@ module Lyricli
       end
       track
     end
       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
   end
 end
index ac16ca649258e2b6760ca504a40cbbad7a6d8442..33a792af384b4405314d173d6ceb8374781c07ef 100644 (file)
Binary files a/lyricli-0.0.1.gem and b/lyricli-0.0.1.gem differ
index aec904fd541208f963a53ffce299a9abf9e6a92d..41e6cf322c39400283d82cdbd8e543d1823a3264 100644 (file)
@@ -11,6 +11,8 @@ Gem::Specification.new do |s|
   s.files += Dir['[A-Z]*'] + Dir['spec/**/*']
   s.files += Dir['lib/**/*.json']
 
   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'
   # Runtime Dependencies
   s.add_runtime_dependency 'nokogiri', '~> 1.5.5'
   s.add_runtime_dependency 'multi_json', '~> 1.3.6'