5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/srs/cli/cat.rb', line 5
def run!(arguments)
if not SRS::Workspace.initialised? then
puts "Current directory is not an SRS Workspace"
return 3
end
sha1 = arguments.shift
sha1_start = sha1[0..1]
sha1_rest = sha1[2..-1]
VALID_SECTIONS.each do |section|
datafile = "#{section}/#{sha1_start}/#{sha1_rest}"
if File.exists?(datafile) then
contents = File.open(datafile, "r"){ |file| file.read }
puts contents
return 0
end
end
puts "No content with that ID exists"
return 4
end
|