3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/shepherd/commands/show.rb', line 3
def init
@opts = Trollop::options do
banner <<-EOB
usage: shep show [sheep] [options]
options are:
EOB
opt :help, "show me and exit"
end
if name = ARGV.shift
sheep = Shepherd::Db.new.get_first_row "select * from sheeps where name = ?", name
if sheep
puts "
id: \e[1;35m#{sheep[0]}\e[0;0m
path: \e[1;34m#{sheep[1]}\e[0;0m
name: \e[1;32m#{sheep[2]}\e[0;0m
state: #{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]}
updated at #{sheep[8]}
"
else
puts "[shep] exit 6: there is no such sheep: #{name}"
exit 6
end
else
puts "no sheep specified"
end
end
|