locd 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/locd/cli/command/agent.rb +52 -69
- data/lib/locd/cli/command/agent/add.rb +74 -0
- data/locd.gemspec +2 -2
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6438af1b2410389af392d28a64141b6dd028c38
|
4
|
+
data.tar.gz: 2def809840b2b7be95a91c892fa04643da9e574d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3cd7af583a45013c1fa5528f7b99a8bd9977dcc4c8f104618df2bdbf2e48c43d7616c8f2593d3a72452ba04fa02bdf27a54c9a95346282a3c4ba7088015a091
|
7
|
+
data.tar.gz: d3fe5aea5eaa00f5bc881204443fc356a344585300a4e75c78af10493b2c21ce91271e6de9ae89017ad66de2ab33eb9d99b0bf72b65177e636445c5c79beb02b
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.8
|
@@ -107,7 +107,8 @@ class Locd::CLI::Command::Agent < Locd::CLI::Command::Base
|
|
107
107
|
|
108
108
|
shared_option :long,
|
109
109
|
groups: :respond_with_agents,
|
110
|
-
|
110
|
+
group: "Display",
|
111
|
+
desc: "Display agent details table",
|
111
112
|
aliases: '-l',
|
112
113
|
type: :boolean
|
113
114
|
|
@@ -149,6 +150,7 @@ class Locd::CLI::Command::Agent < Locd::CLI::Command::Base
|
|
149
150
|
|
150
151
|
shared_option :all,
|
151
152
|
groups: :multi,
|
153
|
+
group: "Pattern",
|
152
154
|
desc: "Apply to ALL agents that PATTERN matches",
|
153
155
|
aliases: '-a',
|
154
156
|
type: :boolean
|
@@ -209,6 +211,31 @@ class Locd::CLI::Command::Agent < Locd::CLI::Command::Base
|
|
209
211
|
default: true
|
210
212
|
|
211
213
|
|
214
|
+
# `:start` Group
|
215
|
+
# --------------------------------------------------------------------------
|
216
|
+
#
|
217
|
+
# Relevant options when starting agents.
|
218
|
+
#
|
219
|
+
|
220
|
+
shared_option :load,
|
221
|
+
groups: :start,
|
222
|
+
desc: "Load the agent before starting",
|
223
|
+
type: :boolean,
|
224
|
+
default: true
|
225
|
+
|
226
|
+
shared_option :force,
|
227
|
+
groups: :start,
|
228
|
+
desc: "Force loading of agent even if it's disabled",
|
229
|
+
type: :boolean,
|
230
|
+
default: false
|
231
|
+
|
232
|
+
shared_option :enable,
|
233
|
+
groups: :start,
|
234
|
+
desc: "Set `launchd` *Disabled* key to `false`",
|
235
|
+
type: :boolean,
|
236
|
+
default: false
|
237
|
+
|
238
|
+
|
212
239
|
# Commands
|
213
240
|
# ============================================================================
|
214
241
|
|
@@ -234,7 +261,7 @@ class Locd::CLI::Command::Agent < Locd::CLI::Command::Base
|
|
234
261
|
end
|
235
262
|
|
236
263
|
|
237
|
-
desc "plist PATTERN",
|
264
|
+
desc "plist PATTERN [OPTIONS]",
|
238
265
|
"Print an agent's launchd property list"
|
239
266
|
|
240
267
|
include_options groups: :pattern
|
@@ -267,44 +294,7 @@ class Locd::CLI::Command::Agent < Locd::CLI::Command::Base
|
|
267
294
|
# Commands for Manipulating Agent Definitions
|
268
295
|
# ----------------------------------------------------------------------------
|
269
296
|
|
270
|
-
|
271
|
-
"Add an agent that runs a command in the current directory"
|
272
|
-
|
273
|
-
include_options groups: [:write, :add, :respond_with_agents]
|
274
|
-
|
275
|
-
def add *cmd_template, **kwds
|
276
|
-
logger.trace __method__.to_s,
|
277
|
-
cmd_template: cmd_template,
|
278
|
-
kwds: kwds,
|
279
|
-
options: options
|
280
|
-
|
281
|
-
# Merge all the keywords together into the format needed to call
|
282
|
-
# {Locd::Agent.add}
|
283
|
-
kwds.merge! **option_kwds( :force, groups: [:write] ),
|
284
|
-
cmd_template: cmd_template
|
285
|
-
|
286
|
-
# Check args
|
287
|
-
|
288
|
-
# `:cmd_template` can not be empty at this point
|
289
|
-
if kwds[:cmd_template].empty? || kwds[:cmd_template].all?( &:empty? )
|
290
|
-
raise Thor::RequiredArgumentMissingError,
|
291
|
-
"CMD_TEMPLATE argument is required to add an agent"
|
292
|
-
end
|
293
|
-
|
294
|
-
# Need a `:label` too
|
295
|
-
unless t.non_empty_str === kwds[:label]
|
296
|
-
raise Thor::RequiredArgumentMissingError,
|
297
|
-
"--label=LABEL option is required to add an agent"
|
298
|
-
end
|
299
|
-
|
300
|
-
# Do the add
|
301
|
-
agent = agent_class.add **kwds
|
302
|
-
|
303
|
-
# Reload (unless we were told not to... usually you want to reload)
|
304
|
-
agent.reload if options[:load]
|
305
|
-
|
306
|
-
respond agent
|
307
|
-
end
|
297
|
+
require_relative './agent/add'
|
308
298
|
|
309
299
|
|
310
300
|
desc "update PATTERN [OPTIONS] [-- CMD_TEMPLATE...]",
|
@@ -325,7 +315,7 @@ class Locd::CLI::Command::Agent < Locd::CLI::Command::Base
|
|
325
315
|
end
|
326
316
|
|
327
317
|
|
328
|
-
desc "rm PATTERN",
|
318
|
+
desc "rm PATTERN [OPTIONS]",
|
329
319
|
"Remove (uninstall, delete) a agent"
|
330
320
|
|
331
321
|
map remove: :rm
|
@@ -339,9 +329,6 @@ class Locd::CLI::Command::Agent < Locd::CLI::Command::Base
|
|
339
329
|
|
340
330
|
def rm pattern
|
341
331
|
kwds = option_kwds :logs
|
342
|
-
|
343
|
-
logger.debug "kwds", kwds
|
344
|
-
|
345
332
|
find_multi!( pattern ).each { |agent| agent.remove **kwds }
|
346
333
|
end
|
347
334
|
|
@@ -349,35 +336,21 @@ class Locd::CLI::Command::Agent < Locd::CLI::Command::Base
|
|
349
336
|
# Commands for Manipulating Agent State
|
350
337
|
# --------------------------------------------------------------------------
|
351
338
|
|
352
|
-
desc "start PATTERN",
|
339
|
+
desc "start PATTERN [OPTIONS]",
|
353
340
|
"Start an agent"
|
354
341
|
|
355
|
-
include_options groups: :pattern
|
356
|
-
|
357
|
-
option :load,
|
358
|
-
desc: "Load the agent before starting",
|
359
|
-
type: :boolean,
|
360
|
-
default: true
|
361
|
-
|
362
|
-
option :force,
|
363
|
-
desc: "Force loading of agent even if it's disabled",
|
364
|
-
type: :boolean,
|
365
|
-
default: false
|
366
|
-
|
367
|
-
option :enable,
|
368
|
-
desc: "Set `launchd` *Disabled* key to `false`",
|
369
|
-
type: :boolean,
|
370
|
-
default: false
|
342
|
+
include_options groups: [ :pattern, :multi, :start ]
|
371
343
|
|
372
344
|
def start pattern
|
373
|
-
|
345
|
+
kwds = option_kwds :load, :force, :enable
|
346
|
+
find_mutli!( pattern ).each { |agent| agent.start **kwds }
|
374
347
|
end
|
375
348
|
|
376
349
|
|
377
|
-
desc "stop PATTERN",
|
350
|
+
desc "stop PATTERN [OPTIONS]",
|
378
351
|
"Stop an agent"
|
379
352
|
|
380
|
-
include_options groups: [:pattern, :stop]
|
353
|
+
include_options groups: [:pattern, :multi, :stop]
|
381
354
|
|
382
355
|
option :unload,
|
383
356
|
desc: "Unload the agent from `launchd` after stopping",
|
@@ -390,11 +363,12 @@ class Locd::CLI::Command::Agent < Locd::CLI::Command::Base
|
|
390
363
|
default: false
|
391
364
|
|
392
365
|
def stop pattern
|
393
|
-
|
366
|
+
kwds = option_kwds :unload, :disable
|
367
|
+
find_multi!( pattern ).each { |agent| agent.stop **kwds }
|
394
368
|
end
|
395
369
|
|
396
370
|
|
397
|
-
desc "restart PATTERN",
|
371
|
+
desc "restart PATTERN [OPTIONS]",
|
398
372
|
"Restart an agent"
|
399
373
|
|
400
374
|
include_options groups: [:pattern, :multi, :stop]
|
@@ -416,7 +390,6 @@ class Locd::CLI::Command::Agent < Locd::CLI::Command::Base
|
|
416
390
|
|
417
391
|
def restart pattern
|
418
392
|
kwds = option_kwds :reload, :force, :enable
|
419
|
-
|
420
393
|
find_multi!( pattern ).each { |agent| agent.restart **kwds }
|
421
394
|
end
|
422
395
|
|
@@ -424,14 +397,24 @@ class Locd::CLI::Command::Agent < Locd::CLI::Command::Base
|
|
424
397
|
# Assorted Other Commands
|
425
398
|
# ----------------------------------------------------------------------------
|
426
399
|
|
427
|
-
desc "open PATTERN",
|
400
|
+
desc "open PATTERN [OPTIONS]",
|
428
401
|
"Open an agent's URL in the browser"
|
429
402
|
|
430
|
-
include_options groups: [:pattern, :multi]
|
403
|
+
include_options groups: [ :pattern, :multi, :start ]
|
404
|
+
|
405
|
+
option :start,
|
406
|
+
desc: %{ Start any stopped agents before opening },
|
407
|
+
type: :boolean,
|
408
|
+
default: true
|
431
409
|
|
432
410
|
def open pattern
|
433
411
|
find_multi!( pattern ).each do |agent|
|
412
|
+
if options[:start] && agent.stopped?
|
413
|
+
agent.start **option_kwds( groups: :start )
|
414
|
+
end
|
415
|
+
|
434
416
|
Cmds! "open %s", agent.url
|
417
|
+
|
435
418
|
logger.info "Opened agent `#{ agent.label }` at #{ agent.url }"
|
436
419
|
end
|
437
420
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
|
5
|
+
# Namespace
|
6
|
+
# =======================================================================
|
7
|
+
|
8
|
+
module Locd
|
9
|
+
module CLI
|
10
|
+
module Command
|
11
|
+
|
12
|
+
|
13
|
+
# Definitions
|
14
|
+
# =======================================================================
|
15
|
+
|
16
|
+
class Agent < Locd::CLI::Command::Base
|
17
|
+
|
18
|
+
desc "add [OPTIONS] -- CMD_TEMPLATE...",
|
19
|
+
"Add an agent that runs a command in the current directory"
|
20
|
+
|
21
|
+
example <<~END
|
22
|
+
Serve Yard docs for a Ruby gem in development
|
23
|
+
|
24
|
+
Defines a Yard server working in the current directory that will be
|
25
|
+
available at http://yard.my_gem.test:8888 (unless Loc'd is running on a
|
26
|
+
different port than 8888).
|
27
|
+
|
28
|
+
locd site add --name=yard.my_gem.test -- bundle exec yard server --reload --port {port} --bind {bind}
|
29
|
+
|
30
|
+
END
|
31
|
+
|
32
|
+
include_options groups: [:write, :add, :respond_with_agents]
|
33
|
+
|
34
|
+
def add *cmd_template, **kwds
|
35
|
+
logger.trace __method__.to_s,
|
36
|
+
cmd_template: cmd_template,
|
37
|
+
kwds: kwds,
|
38
|
+
options: options
|
39
|
+
|
40
|
+
# Merge all the keywords together into the format needed to call
|
41
|
+
# {Locd::Agent.add}
|
42
|
+
kwds.merge! **option_kwds( :force, groups: [:write] ),
|
43
|
+
cmd_template: cmd_template
|
44
|
+
|
45
|
+
# Check args
|
46
|
+
|
47
|
+
# `:cmd_template` can not be empty at this point
|
48
|
+
if kwds[:cmd_template].empty? || kwds[:cmd_template].all?( &:empty? )
|
49
|
+
raise Thor::RequiredArgumentMissingError,
|
50
|
+
"CMD_TEMPLATE argument is required to add an agent"
|
51
|
+
end
|
52
|
+
|
53
|
+
# Need a `:label` too
|
54
|
+
unless t.non_empty_str === kwds[:label]
|
55
|
+
raise Thor::RequiredArgumentMissingError,
|
56
|
+
"--label=LABEL option is required to add an agent"
|
57
|
+
end
|
58
|
+
|
59
|
+
# Do the add
|
60
|
+
agent = agent_class.add **kwds
|
61
|
+
|
62
|
+
# Reload (unless we were told not to... usually you want to reload)
|
63
|
+
agent.reload if options[:load]
|
64
|
+
|
65
|
+
respond agent
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# /Namespace
|
70
|
+
# =======================================================================
|
71
|
+
|
72
|
+
end # module Command
|
73
|
+
end # module CLI
|
74
|
+
end # module Locd
|
data/locd.gemspec
CHANGED
@@ -47,7 +47,7 @@ Gem::Specification.new do |spec|
|
|
47
47
|
# ----------------------------------------------------------------------------
|
48
48
|
|
49
49
|
# My guns
|
50
|
-
spec.add_dependency "nrser", '~> 0.3.
|
50
|
+
spec.add_dependency "nrser", '~> 0.3.5'
|
51
51
|
|
52
52
|
# Used to process command templates from projects' `//dev/locd.yml` files
|
53
53
|
spec.add_dependency "cmds", ">= 0.2.10"
|
@@ -59,7 +59,7 @@ Gem::Specification.new do |spec|
|
|
59
59
|
spec.add_dependency 'plist', '~> 3.4'
|
60
60
|
|
61
61
|
# Atli, my fork of Thor for CLI interface
|
62
|
-
spec.add_dependency 'atli', '~> 0.1.
|
62
|
+
spec.add_dependency 'atli', '~> 0.1.8'
|
63
63
|
|
64
64
|
#
|
65
65
|
# spec.add_dependency 'terminal-table', '~> 1.8'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: locd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nrser
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.3.
|
117
|
+
version: 0.3.5
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.3.
|
124
|
+
version: 0.3.5
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: cmds
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 0.1.
|
173
|
+
version: 0.1.8
|
174
174
|
type: :runtime
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 0.1.
|
180
|
+
version: 0.1.8
|
181
181
|
description:
|
182
182
|
email:
|
183
183
|
- neil@ztkae.com
|
@@ -214,6 +214,7 @@ files:
|
|
214
214
|
- lib/locd/cli.rb
|
215
215
|
- lib/locd/cli/command.rb
|
216
216
|
- lib/locd/cli/command/agent.rb
|
217
|
+
- lib/locd/cli/command/agent/add.rb
|
217
218
|
- lib/locd/cli/command/base.rb
|
218
219
|
- lib/locd/cli/command/job.rb
|
219
220
|
- lib/locd/cli/command/main.rb
|