Sha256: 0ec22e84ca37a31126eef5dd215f0216b190feb1973e614940bc2fdb78c112d8
Contents?: true
Size: 1.42 KB
Versions: 3
Compression:
Stored size: 1.42 KB
Contents
module Shepherd::Command class Show def init @opts = Trollop::options do banner <<-EOB usage: shep show [sheep] [options] options are: EOB opt :oneline, "print one sheep by one line" opt :help, "show me and exit" end # This is what we should show. +:everyone+ means every sheep we got # and ARGV[0] would be the name of the one specified sheep. @what = ARGV[0] || :everyone case @what when :everyone Shepherd::Db.new.execute "select * from sheeps" do |sheep| if !@opts[:oneline] puts "#{sheep[0]}. \e[1;32m#{sheep[1]}\e[0;0m in \e[1;34m#{sheep[2]}\e[0;0m #{sheep[3].to_nice} files #{sheep[4].to_nice} lines #{sheep[5].to_nice} chars #{Shepherd::Utils.nice_bytes(sheep[6])} (#{sheep[6].to_nice} bytes) " else puts "#{sheep[0]}. \e[1;32m#{sheep[1]}\e[0;0m in \e[1;34m#{sheep[2]}\e[0;0m" end end else sheep = Shepherd::Db.new.get_first_row "select * from sheeps where name = ?", @what if sheep puts <<-EOP #{sheep[0]}. \e[1;32m#{sheep[1]}\e[0;0m in \e[1;34m#{sheep[2]}\e[0;0m #{sheep[3].to_nice} files #{sheep[4].to_nice} lines #{sheep[5].to_nice} chars #{Shepherd::Utils.nice_bytes(sheep[6])} (#{sheep[6].to_nice} bytes) initialized at #{sheep[7]} EOP else puts "[shep] exit 6: there is no such sheep: #{@what}" exit 6 end end end def desc "list sheeps you have initialized" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
shepherd-0.2.0 | lib/shepherd/commands/show.rb |
shepherd-0.1.4 | lib/shepherd/commands/show.rb |
shepherd-0.1.3 | lib/shepherd/commands/show.rb |