-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathirk
executable file
·70 lines (59 loc) · 1.09 KB
/
irk
1
2
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env ruby
require "readline"
include Readline
def get_lines(pattern = '')
@lines = `rake -T #{pattern}`.split("\n")
@lines.shift
@lines = @lines.each do |l|
l.gsub!(/^rake /, '')
l.gsub!(/\s*#.*/, '')
l.strip
end
end
def execute(i, args = '')
cmd = "rake #{@lines[i]} #{ARGV.join(' ')} #{args}"
puts cmd
exec cmd
end
def list
@lines.each_with_index do |l,i|
puts " #{i.to_s.rjust(3)}) #{l}"
end
end
get_lines(ARGV[0])
ARGV.shift
case @lines.size
when 0
puts "no tasks found. sorry"
exit
when 1
execute(0)
end
list
loop do
a = readline('> ').strip
HISTORY.push(a)
case a
when /^(\d+)\s*(.*)?$/
execute($1.to_i, $2)
when /^e\s*(\d+)$/
system "rake -D #{@lines[$1.to_i]}"
when /^t\s*(.*)$/
get_lines($1)
list
when /^l$/
list
when /^q$/
break
when /^\?$/
puts "e NN : execute task"
puts "NN : execute task"
puts "t PPPP: set new search pattern"
puts "l : list found tasks (again)"
puts "q : quit"
break
else
puts "Huh? (q to quit, ? for help)"
end
end
puts "bye"