lunchy 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.md +10 -0
- data/README.md +3 -3
- data/bin/lunchy +2 -1
- data/lib/lunchy.rb +24 -9
- data/lunchy.gemspec +2 -3
- metadata +4 -3
data/History.md
ADDED
data/README.md
CHANGED
@@ -3,7 +3,7 @@ lunchy
|
|
3
3
|
|
4
4
|
A friendly wrapper for launchctl. Start your agents and go to lunch!
|
5
5
|
|
6
|
-
Don't you hate OSX's launchctl? You have to give it exact filenames. The syntax is annoying different from Linux's simple init system and overly verbose. It's just not a very developer-friendly tool.
|
6
|
+
Don't you hate OSX's launchctl? You have to give it exact filenames. The syntax is annoying different from Linux's nice, simple init system and overly verbose. It's just not a very developer-friendly tool.
|
7
7
|
|
8
8
|
Lunchy aims to be that friendly tool by wrapping launchctl and providing a few simple operations that you perform all the time:
|
9
9
|
|
@@ -13,7 +13,7 @@ Lunchy aims to be that friendly tool by wrapping launchctl and providing a few s
|
|
13
13
|
- restart [pattern]
|
14
14
|
- status [pattern]
|
15
15
|
|
16
|
-
where pattern is just a substring that matches the agent's plist filename.
|
16
|
+
where pattern is just a substring that matches the agent's plist filename. If you don't use a unique pattern, Lunchy will warn you of this and give you a list of the matching items instead.
|
17
17
|
|
18
18
|
So instead of:
|
19
19
|
|
@@ -32,7 +32,7 @@ and:
|
|
32
32
|
io.redis.redis-server
|
33
33
|
org.mongodb.mongod
|
34
34
|
|
35
|
-
Lunchy isn't a great name but gem names are like domains, most of the good ones are taken. :-(
|
35
|
+
The original name was supposed to be launchy. Lunchy isn't a great name but gem names are like domains, most of the good ones are taken. :-(
|
36
36
|
|
37
37
|
|
38
38
|
Installation
|
data/bin/lunchy
CHANGED
@@ -5,7 +5,7 @@ require 'optparse'
|
|
5
5
|
require 'lunchy'
|
6
6
|
|
7
7
|
CONFIG = { :verbose => false }
|
8
|
-
OPERATIONS = %w(start stop restart ls status)
|
8
|
+
OPERATIONS = %w(start stop restart ls list status)
|
9
9
|
|
10
10
|
option_parser = OptionParser.new do |opts|
|
11
11
|
opts.banner = "Lunchy #{Lunchy::VERSION}, the friendly launchctl wrapper\nUsage: #{__FILE__} [#{OPERATIONS.join('|')}] [options]"
|
@@ -19,6 +19,7 @@ option_parser = OptionParser.new do |opts|
|
|
19
19
|
Supported commands:
|
20
20
|
|
21
21
|
ls [pattern] Show the list of installed agents, with optional [pattern] filter
|
22
|
+
list [pattern] Alias for 'ls'
|
22
23
|
start [pattern] Start the first agent matching [pattern]
|
23
24
|
stop [pattern] Stop the first agent matching [pattern]
|
24
25
|
restart [pattern] Stop and start the first agent matching [pattern]
|
data/lib/lunchy.rb
CHANGED
@@ -1,20 +1,30 @@
|
|
1
1
|
class Lunchy
|
2
|
-
VERSION = '0.
|
2
|
+
VERSION = '0.2.0'
|
3
3
|
|
4
4
|
def start(params)
|
5
5
|
raise ArgumentError, "start [name]" if params.empty?
|
6
6
|
name = params[0]
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
files = plists.select {|k,v| k =~ /#{name}/i }
|
8
|
+
if files.length > 1
|
9
|
+
return puts "Multiple daemons found matching '#{name}'. You need to be more specific. Matches found are:\n" + files.keys.join("\n")
|
10
|
+
elsif files.length == 0
|
11
|
+
return puts "No daemon found matching '#{name}'" if !name
|
12
|
+
else
|
13
|
+
execute("launchctl load #{files.values.first.inspect}")
|
14
|
+
end
|
10
15
|
end
|
11
16
|
|
12
17
|
def stop(params)
|
13
18
|
raise ArgumentError, "stop [name]" if params.empty?
|
14
19
|
name = params[0]
|
15
|
-
|
16
|
-
|
17
|
-
|
20
|
+
files = plists.select {|k,v| k =~ /#{name}/i }
|
21
|
+
if files.length > 1
|
22
|
+
return puts "Multiple daemons found matching '#{name}'. You need to be more specific. Matches found are:\n" + files.keys.join("\n")
|
23
|
+
elsif files.length == 0
|
24
|
+
return puts "No daemon found matching '#{name}'" if !name
|
25
|
+
else
|
26
|
+
execute("launchctl unload #{files.values.first.inspect}")
|
27
|
+
end
|
18
28
|
end
|
19
29
|
|
20
30
|
def restart(params)
|
@@ -25,6 +35,10 @@ class Lunchy
|
|
25
35
|
def status(params)
|
26
36
|
pattern = params[0]
|
27
37
|
cmd = "launchctl list"
|
38
|
+
if !verbose?
|
39
|
+
agents = "(" + plists.keys.join("|") + ")"
|
40
|
+
cmd << " | grep -i -E \"#{agents}\""
|
41
|
+
end
|
28
42
|
cmd << " | grep -i \"#{pattern}\"" if pattern
|
29
43
|
execute(cmd)
|
30
44
|
end
|
@@ -34,6 +48,7 @@ class Lunchy
|
|
34
48
|
agents = agents.grep(/#{params[0]}/) if !params.empty?
|
35
49
|
puts agents.sort.join("\n")
|
36
50
|
end
|
51
|
+
alias_method :list, :ls
|
37
52
|
|
38
53
|
private
|
39
54
|
|
@@ -46,8 +61,8 @@ class Lunchy
|
|
46
61
|
@plists ||= begin
|
47
62
|
plists = {}
|
48
63
|
%w(/Library/LaunchAgents ~/Library/LaunchAgents).each do |dir|
|
49
|
-
Dir["#{File.expand_path(dir)}/*.plist"].
|
50
|
-
|
64
|
+
Dir["#{File.expand_path(dir)}/*.plist"].inject(plists) do |memo, filename|
|
65
|
+
memo[File.basename(filename, ".plist")] = filename; memo
|
51
66
|
end
|
52
67
|
end
|
53
68
|
plists
|
data/lunchy.gemspec
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require "lunchy"
|
2
|
+
require "./lib/lunchy"
|
4
3
|
|
5
4
|
Gem::Specification.new do |s|
|
6
5
|
s.name = "lunchy"
|
@@ -8,7 +7,7 @@ Gem::Specification.new do |s|
|
|
8
7
|
s.platform = Gem::Platform::RUBY
|
9
8
|
s.authors = ["Mike Perham"]
|
10
9
|
s.email = ["mperham@gmail.com"]
|
11
|
-
s.homepage = "http://github.com/mperham/
|
10
|
+
s.homepage = "http://github.com/mperham/lunchy"
|
12
11
|
s.summary = s.description = %q{Friendly wrapper around launchctl}
|
13
12
|
|
14
13
|
s.files = `git ls-files`.split("\n")
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: lunchy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mike Perham
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-03-
|
13
|
+
date: 2011-03-29 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -24,13 +24,14 @@ extensions: []
|
|
24
24
|
extra_rdoc_files: []
|
25
25
|
|
26
26
|
files:
|
27
|
+
- History.md
|
27
28
|
- LICENSE
|
28
29
|
- README.md
|
29
30
|
- bin/lunchy
|
30
31
|
- lib/lunchy.rb
|
31
32
|
- lunchy.gemspec
|
32
33
|
has_rdoc: true
|
33
|
-
homepage: http://github.com/mperham/
|
34
|
+
homepage: http://github.com/mperham/lunchy
|
34
35
|
licenses: []
|
35
36
|
|
36
37
|
post_install_message:
|