bin/lt in ratch-0.2.2 vs bin/lt in ratch-0.2.3
- old
+ new
@@ -1,15 +1,15 @@
#! /usr/bin/ruby1.8
# scan task scripts for descriptions
-def script_desc( dir )
+def script_desc(dir)
help = {}
- files = Dir.glob( File.join( dir, '*' ) )
+ files = Dir.glob(File.join(dir,'**/*'))
files.each do |fname|
- next if FileTest.directory?( fname )
- next unless FileTest.executable?( fname )
+ next if FileTest.directory?(fname)
+ next unless FileTest.executable?(fname)
desc = ''
File.open(fname) do |f|
line = ''
until f.eof?
line = f.gets
@@ -21,36 +21,36 @@
else
desc = nil; break
end
end
end
- help[File.basename(fname)] = desc
+ help[fname] = desc
end
help
end
-def show( dir )
- tasks = script_desc( dir )
+def show(dir)
+ tasks = script_desc(dir)
max = tasks.keys.max{ |a,b| a.size <=> b.size }.size
if dir == ''
max += 4 + 2
else
max += dir.size + 2
end
+ tasks = tasks.sort_by{|k,v| k }
tasks.each do |name, sum|
- #sum = Sake.help_summary( type )
if dir == ''
- cmd = "sake #{name}"
+ cmd = "ratch #{name}"
else
- cmd = File.join( dir.chomp('/'), name )
+ cmd = name
end
puts "%-#{max}s # %s" % [cmd, sum]
end
end
dir = ARGV[0] || '.'
-if File.directory?( dir )
+if File.directory?(dir)
show( dir )
else
puts "#{dir} is not a directory"
end