lunchy 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +5 -0
  3. data/bin/lunchy +6 -0
  4. data/lib/lunchy.rb +18 -6
  5. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ce0c016e1ab90df8712085757b64b4aa1374206
4
- data.tar.gz: 0c7b03c566499c87a36f293fe9fc026bf9dde41e
3
+ metadata.gz: 07dc58fb1d8df9832cdd1e06b8c0912b140f92ce
4
+ data.tar.gz: 64a162c04b414c99d58fad53e8fb0bdefca2f92f
5
5
  SHA512:
6
- metadata.gz: 0dffc33645c389fa885dd7a7fc03f844307e592b0195dcb4737ebd2c4703e8abfca3d984d059f17f67ee04b69207c1698324dfe4882b073ed4c5c5a89d66f8f3
7
- data.tar.gz: 1b3a6035f38b14d1f11e98480edb472faa1af3a9b28e2ad8eb02143714c974d16de366c26c65087084f63bae95eb7e945fa8000423db1a3a0e0cfc8382e3a945
6
+ metadata.gz: 49a0d51f2d0994bd14a2592d8c9614f42a1272a95bc685677402728159a04d9c348d5dcc8fde471027e22d5e88d9140ddbfbdcaa373804dc2483c1f1f214fd90
7
+ data.tar.gz: 50446916542c4a3aaf1a09e918ff6582af4b6357dc70f7b1b797248a29b3ea572db8d22efab07f03d5fc4f4479f2c2e5adcd17998ee730720e9479b065b2eec2
data/History.md CHANGED
@@ -1,6 +1,11 @@
1
1
  Changes
2
2
  ================
3
3
 
4
+ 0.9.0
5
+ ----
6
+
7
+ - Add flag for exact match - [bunnymatic](https://github.com/bunnymatic) via [#51](https://github.com/eddiezane/lunchy/pull/51)
8
+
4
9
  0.8.0
5
10
  ----
6
11
 
data/bin/lunchy CHANGED
@@ -11,6 +11,10 @@ option_parser = OptionParser.new do |opts|
11
11
  opts.banner = "Lunchy #{Lunchy::VERSION}, the friendly launchctl wrapper\n" \
12
12
  "Usage: #{File.basename(__FILE__)} [#{OPERATIONS.join('|')}] [options]"
13
13
 
14
+ opts.on("-x", "--exact", "Force exact (case insensitive) match when specifying a [pattern]") do
15
+ CONFIG[:exact] = true
16
+ end
17
+
14
18
  opts.on("-F", "--force", "Force start (disabled) agents") do |verbose|
15
19
  CONFIG[:force] = true
16
20
  end
@@ -48,6 +52,7 @@ Supported commands:
48
52
 
49
53
  -w will persist the start/stop command so the agent will load on startup or never load, respectively.
50
54
  -l will display absolute paths of the launchctl daemon files when showing list of installed agents.
55
+ -x will force exact matching of the [pattern] for any command that uses a pattern
51
56
 
52
57
  Example:
53
58
  lunchy ls
@@ -58,6 +63,7 @@ Example:
58
63
  lunchy install /usr/local/Cellar/redis/2.2.2/io.redis.redis-server.plist
59
64
  lunchy show redis
60
65
  lunchy edit mongo
66
+ lunchy uninstall -x elasticsearch # will not try to uninstall elasticsearch14
61
67
 
62
68
  Note: if you run lunchy as root, you can manage daemons in /Library/LaunchDaemons also.
63
69
  EOS
data/lib/lunchy.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'fileutils'
2
2
 
3
3
  class Lunchy
4
- VERSION = '0.8.0'
4
+ VERSION = '0.9.0'
5
5
 
6
6
  def start(params)
7
7
  raise ArgumentError, "start [-wF] [name]" if params.empty?
@@ -27,9 +27,8 @@ class Lunchy
27
27
  end
28
28
 
29
29
  def status(params)
30
- pattern = params[0]
30
+ pattern = pattern_for_grep params[0]
31
31
  cmd = "launchctl list"
32
-
33
32
  unless verbose?
34
33
  agents = plists.keys.map { |k| "-e \"#{k}\"" }.join(" ")
35
34
  cmd << " | grep -i #{agents}"
@@ -41,8 +40,9 @@ class Lunchy
41
40
  end
42
41
 
43
42
  def ls(params)
43
+ pattern = pattern_regex params[0]
44
44
  agents = plists.keys
45
- agents = agents.grep(/#{params[0]}/i) if !params.empty?
45
+ agents = agents.grep(pattern) if !params.empty?
46
46
  if long
47
47
  puts agents.map { |agent| plists[agent] }.sort.join("\n")
48
48
  else
@@ -104,6 +104,10 @@ class Lunchy
104
104
 
105
105
  private
106
106
 
107
+ def exact
108
+ CONFIG[:exact]
109
+ end
110
+
107
111
  def force
108
112
  CONFIG[:force] and '-F '
109
113
  end
@@ -120,14 +124,22 @@ class Lunchy
120
124
  CONFIG[:symlink]
121
125
  end
122
126
 
127
+ def pattern_for_grep(s)
128
+ exact ? "\\b#{s}\\b" : s if s
129
+ end
130
+
131
+ def pattern_regex(s)
132
+ /#{pattern_for_grep(s)}/i
133
+ end
134
+
123
135
  def with_match(name)
124
- files = plists.select {|k,_| k =~ /#{name}/i }
136
+ files = plists.select {|k,_| k =~ pattern_regex(name) }
125
137
  files = Hash[files] if files.is_a?(Array) # ruby 1.8
126
138
 
127
139
  if files.size > 1
128
140
  puts "Multiple daemons found matching '#{name}'. You need to be more specific. Matches found are:\n#{files.keys.join("\n")}"
129
141
  elsif files.empty?
130
- puts "No daemon found matching '#{name}'" unless name
142
+ puts "No daemon found matching '#{name}' #{exact ? 'exactly' : nil}" if name
131
143
  else
132
144
  yield(*files.to_a.first)
133
145
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lunchy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Perham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-02 00:00:00.000000000 Z
11
+ date: 2015-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  version: '0'
62
62
  requirements: []
63
63
  rubyforge_project:
64
- rubygems_version: 2.2.2
64
+ rubygems_version: 2.4.5
65
65
  signing_key:
66
66
  specification_version: 4
67
67
  summary: Friendly wrapper around launchctl