after 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/VERSION +1 -1
- data/bin/after +5 -3
- data/lib/after.rb +17 -10
- metadata +5 -3
data/ChangeLog
ADDED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.1
|
data/bin/after
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
3
|
if ARGV.include?('-h') || ARGV.include?('--help') || ARGV.length == 0
|
4
|
-
puts 'syntax: [-
|
5
|
-
puts 'ex: after ruby ls -l'
|
4
|
+
puts 'syntax: [-q : quit mode (don\'t show output for when process ends)] [-l or --list : only list matches] [-p pid] "command string to match" (some other command to run with its args on completion)'
|
5
|
+
puts 'ex: after ruby ls -l # run ls -l after any ruby processes exit'
|
6
6
|
puts 'after -l # list all running processes'
|
7
|
-
puts "after irb \"ls | grep l\""
|
7
|
+
puts "after irb \"ls | grep l\" # complex command to run after irb terminates"
|
8
|
+
puts "after -p 3704 ls # run ls after process with PID 3704 terminates"
|
9
|
+
puts "after -q -p 3704 ls # run ls after PID 3704 terminates, don't output anything except the output of ls"
|
8
10
|
exit
|
9
11
|
end
|
10
12
|
|
data/lib/after.rb
CHANGED
@@ -13,7 +13,7 @@ class After
|
|
13
13
|
if OS.windows?
|
14
14
|
procs = WMI::Win32_Process.find(:all)
|
15
15
|
for proc in procs
|
16
|
-
procs_by_pid[proc.ProcessId] = proc.
|
16
|
+
procs_by_pid[proc.ProcessId] = ("% 20s" % proc.Name.to_s) + ' ' + proc.CommandLine.to_s
|
17
17
|
end
|
18
18
|
else
|
19
19
|
a = `ps -ef` # my linux support isn't very good yet...
|
@@ -25,7 +25,7 @@ class After
|
|
25
25
|
if description.contain?(many_args)
|
26
26
|
next if pid == Process.pid
|
27
27
|
good_pids << [pid, description]
|
28
|
-
if $
|
28
|
+
if $DISPLAY_ALL
|
29
29
|
pps 'found', "% 5d" % pid, description
|
30
30
|
end
|
31
31
|
end
|
@@ -36,10 +36,10 @@ class After
|
|
36
36
|
def self.find_and_wait_for(args)
|
37
37
|
pids = find_pids args
|
38
38
|
if pids.length > 1
|
39
|
-
puts "found more than one -- waiting for all #{pids.map{|pid, name| name}.inspect}"
|
39
|
+
puts "found more than one -- waiting for all -- #{pids.map{|pid, name| name}.inspect}" if $VERBOSE
|
40
40
|
end
|
41
41
|
pids.each{|pid, name|
|
42
|
-
puts "waiting for #{pid} (#{name})"
|
42
|
+
puts "waiting for #{pid} (#{name.strip})" if $VERBOSE
|
43
43
|
WaitPid.wait_nonchild_pid pid
|
44
44
|
}
|
45
45
|
end
|
@@ -48,32 +48,39 @@ class After
|
|
48
48
|
WaitPid.wait_nonchild_pid pid
|
49
49
|
end
|
50
50
|
|
51
|
+
|
51
52
|
# main, really
|
52
53
|
def self.go
|
53
|
-
if ARGV.delete('-
|
54
|
+
if ARGV.delete('-q')
|
55
|
+
$VERBOSE = false
|
56
|
+
else
|
54
57
|
$VERBOSE = true
|
55
|
-
puts 'running in verbose mode'
|
56
58
|
end
|
57
59
|
|
60
|
+
$DISPLAY_ALL = false
|
58
61
|
if ARGV[0].in? ['-l', '--list']
|
59
62
|
ARGV.shift
|
60
|
-
$
|
63
|
+
$DISPLAY_ALL = true
|
61
64
|
query = ARGV.shift || ''
|
62
65
|
got = After.find_pids(query)
|
63
66
|
if got.empty?
|
64
67
|
puts "none found #{query}"
|
65
68
|
end
|
66
|
-
exit #
|
69
|
+
exit # early exit
|
67
70
|
elsif ARGV[0] == '-p'
|
68
71
|
ARGV.shift
|
69
72
|
pid = ARGV.shift
|
70
73
|
puts "waiting for pid #{pid}" if $VERBOSE
|
71
|
-
|
74
|
+
begin
|
75
|
+
After.wait_pid pid.to_i
|
76
|
+
rescue Errno::EPERM
|
77
|
+
p 'pid does not exist maybe it already had exited ' + pid if $VERBOSE
|
78
|
+
end
|
72
79
|
else
|
73
80
|
After.find_and_wait_for(ARGV.shift)
|
74
81
|
end
|
75
82
|
|
76
|
-
puts '
|
83
|
+
puts 'after: now running:', ARGV if $VERBOSE
|
77
84
|
system(*ARGV) if ARGV.length > 0
|
78
85
|
end
|
79
86
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: after
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 61
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 0.8.
|
9
|
+
- 1
|
10
|
+
version: 0.8.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- rogerdpack
|
@@ -94,9 +94,11 @@ executables:
|
|
94
94
|
extensions: []
|
95
95
|
|
96
96
|
extra_rdoc_files:
|
97
|
+
- ChangeLog
|
97
98
|
- README
|
98
99
|
files:
|
99
100
|
- .document
|
101
|
+
- ChangeLog
|
100
102
|
- README
|
101
103
|
- Rakefile
|
102
104
|
- VERSION
|