squared 0.7.13 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +44 -176
- data/README.md +38 -35
- data/lib/squared/common/base.rb +0 -9
- data/lib/squared/common/format.rb +5 -14
- data/lib/squared/common/prompt.rb +30 -32
- data/lib/squared/common/shell.rb +11 -11
- data/lib/squared/common/system.rb +9 -19
- data/lib/squared/common/utils.rb +19 -23
- data/lib/squared/config.rb +5 -12
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +99 -31
- data/lib/squared/workspace/project/base.rb +84 -94
- data/lib/squared/workspace/project/docker.rb +85 -117
- data/lib/squared/workspace/project/git.rb +187 -94
- data/lib/squared/workspace/project/node.rb +184 -177
- data/lib/squared/workspace/project/python.rb +52 -51
- data/lib/squared/workspace/project/ruby.rb +54 -46
- data/lib/squared/workspace/project/support/class.rb +2 -2
- data/lib/squared/workspace/project/support/optionpartition.rb +17 -42
- data/lib/squared/workspace/project/support/utils.rb +15 -22
- data/lib/squared/workspace/repo.rb +10 -7
- data/lib/squared/workspace/series.rb +12 -5
- metadata +2 -2
|
@@ -16,19 +16,19 @@ module Squared
|
|
|
16
16
|
cgroup-parent=b iidfile=p label=q network=b no-cache-filter=b o|output=q platform=q
|
|
17
17
|
q|quiet secret=qq shm-size=b ssh=qq t|tag=b target=b ulimit=q].freeze,
|
|
18
18
|
bake: %w[print list=q set=q].freeze,
|
|
19
|
-
shared: %w[check load no-cache pull push allow=
|
|
20
|
-
sbom=
|
|
19
|
+
shared: %w[check load no-cache pull push allow=q call=b? f|file=p metadata-file=p progress=b provenance=q
|
|
20
|
+
sbom=q].freeze
|
|
21
21
|
}.freeze,
|
|
22
22
|
compose: {
|
|
23
|
-
common: %w[
|
|
24
|
-
project-directory=p p|project-name=
|
|
23
|
+
common: %w[all-resources ansi=b compatibility dry-run env-file=p f|file=p parallel=n profile=b progress=b
|
|
24
|
+
project-directory=p p|project-name=e].freeze,
|
|
25
25
|
build: %w[check no-cache print pull push with-dependencies q|quiet build-arg=qq builder=b m|memory=b
|
|
26
26
|
provenance=q sbom=q ssh=qq].freeze,
|
|
27
27
|
create: %w[build force-recreate no-build no-recreate quiet-pull remove-orphans y|yes pull=b scale=i].freeze,
|
|
28
|
-
exec: %w[d|detach privileged e|env=qq index=i T|no-
|
|
28
|
+
exec: %w[d|detach privileged e|env=qq index=i T|no-TTY=b? user=e w|workdir=q].freeze,
|
|
29
29
|
run: %w[build d|detach no-deps q|quiet quiet-build quiet-pull remove-orphans rm P|service-ports use-aliases
|
|
30
30
|
cap-add=b cap-drop=b entrypoint=q e|env=qq env-from-file=p i|interactive=b? l|label=q name=b
|
|
31
|
-
T|no-
|
|
31
|
+
T|no-TTY=b? p|publish=q pull=b u|user=e v|volume=q w|workdir=q].freeze,
|
|
32
32
|
up: %w[abort-on-container-exit abort-on-container-failure always-recreate-deps attach-dependencies build
|
|
33
33
|
d|detach force-recreate menu no-build no-color no-deps no-log-prefix no-recreate no-start quiet-build
|
|
34
34
|
quiet-pull remove-orphans V|renew-anon-volumes timestamps wait w|watch y|yes attach=b
|
|
@@ -38,9 +38,9 @@ module Squared
|
|
|
38
38
|
}.freeze,
|
|
39
39
|
container: {
|
|
40
40
|
create: %w[init i|interactive no-healthcheck oom-kill-disable privileged P|publish-all q|quiet read-only
|
|
41
|
-
rm t|tty
|
|
42
|
-
|
|
43
|
-
device-
|
|
41
|
+
rm t|tty use-api-socket add-host=q annotation=q a|attach=b blkio-weight=i blkio-weight-device=i
|
|
42
|
+
cap-add=b cap-drop=b cgroup-parent=b cgroupns=b cidfile=p device=q device-cgroup-rule=q
|
|
43
|
+
device-read-bps=q device-read-iops=q device-write-bps=q device-write-iops=q
|
|
44
44
|
dns=q dns-option=q dns-search=q domainname=b entrypoint=q e|env=qq env-file=p expose=q gpus=q
|
|
45
45
|
group-add=b health-cmd=q health-interval=b health-retries=i health-start-interval=q
|
|
46
46
|
health-start-period=q health-timeout=q hostname=q io-maxbandwidth=b io-maxiops=b ip=b ip6=q ipc=b
|
|
@@ -48,24 +48,23 @@ module Squared
|
|
|
48
48
|
m|memory=b memory-reservation=b memory-swap=n memory-swappiness=n mount=qq name=b network=b
|
|
49
49
|
network-alias=b oom-score-adj=b pid=b pids-limit=n platform=q p|publish=q pull=b restart=b
|
|
50
50
|
runtime=b security-opt=q shm-size=b stop-signal=b stop-timeout=i storage-opt=q sysctl=q tmpfs=q
|
|
51
|
-
ulimit=q u|user=b userns=b uts=b v|volume=
|
|
51
|
+
ulimit=q u|user=b userns=b uts=b v|volume=q volume-driver=b volumes-from=b w|workdir=q].freeze,
|
|
52
52
|
run: %w[d|detach detach-keys=q sig-proxy=b?].freeze,
|
|
53
53
|
update: %w[blkio-weight=i cpu-period=i cpu-quota=i cpu-rt-period=i cpu-rt-runtime=i c|cpu-shares=i cpus=f
|
|
54
54
|
cpuset-cpus=b cpuset-mems=b m|memory=b memory-reservation=b memory-swap=n pids-limit=n
|
|
55
55
|
restart=q].freeze,
|
|
56
|
-
exec: %w[d|detach i|interactive privileged t|tty
|
|
56
|
+
exec: %w[d|detach i|interactive privileged t|tty detach-keys=q e|env=qq env-file=p u|user=e
|
|
57
57
|
w|workdir=q].freeze,
|
|
58
|
-
rm: %w[f|force l|link v|volumes].freeze,
|
|
59
58
|
commit: %w[no-pause a|author=q c|change=q m|message=q pause=b?].freeze,
|
|
60
|
-
inspect: %w[s|size f|format=q].freeze,
|
|
59
|
+
inspect: %w[s|size f|format=q type=b].freeze,
|
|
61
60
|
start: %w[a|attach i|interactive detach-keys=q].freeze,
|
|
62
61
|
stop: %w[s|signal=b t|timeout=i].freeze,
|
|
63
62
|
restart: %w[s|signal=b t|timeout=i].freeze,
|
|
64
63
|
kill: %w[s|signal=b].freeze,
|
|
65
|
-
stats: %w[a|all no-stream no-trunc format|q].freeze
|
|
64
|
+
stats: %w[a|all no-stream no-trunc format|q].freeze,
|
|
65
|
+
attach: %w[no-stdin detach-keys=q sig-proxy=!?].freeze
|
|
66
66
|
}.freeze,
|
|
67
67
|
image: {
|
|
68
|
-
inspect: %w[f|format platform=q].freeze,
|
|
69
68
|
ls: %w[a|all digests no-trunc q|quiet tree f|filter=q format=q].freeze,
|
|
70
69
|
pull: %w[a|all-tags platform=q q|quiet].freeze,
|
|
71
70
|
push: %w[a|all-tags platform=q q|quiet].freeze,
|
|
@@ -82,10 +81,10 @@ module Squared
|
|
|
82
81
|
VAL_DOCKER = {
|
|
83
82
|
run: {
|
|
84
83
|
common: %w[source src destination dst target readonly ro].freeze,
|
|
85
|
-
bind: %w[bind-
|
|
84
|
+
bind: %w[bind-propagation].freeze,
|
|
86
85
|
volume: %w[volume-subpath volume-nocopy volume-opt].freeze,
|
|
87
86
|
tmpfs: %w[tmpfs-size tmpfs-mode].freeze,
|
|
88
|
-
image: %w[image-
|
|
87
|
+
image: %w[image-path].freeze
|
|
89
88
|
}.freeze,
|
|
90
89
|
ls: {
|
|
91
90
|
compose: %w[Name Image Command Service RunningFor Status Ports CreatedAt ExitCode Health ID Labels
|
|
@@ -115,9 +114,9 @@ module Squared
|
|
|
115
114
|
'build' => %i[tag context].freeze,
|
|
116
115
|
'compose' => %i[build create publish run exec up down service].freeze,
|
|
117
116
|
'bake' => %i[build compose check].freeze,
|
|
118
|
-
'image' => %i[ls rm pull push tag save
|
|
119
|
-
'container' => %i[
|
|
120
|
-
|
|
117
|
+
'image' => %i[ls rm pull push tag save].freeze,
|
|
118
|
+
'container' => %i[attach commit create diff exec inspect kill pause restart rm run start stats stop top
|
|
119
|
+
unpause update].freeze,
|
|
121
120
|
'network' => %i[connect disconnect create].freeze,
|
|
122
121
|
'ls' => nil
|
|
123
122
|
})
|
|
@@ -167,7 +166,7 @@ module Squared
|
|
|
167
166
|
when 'compose'
|
|
168
167
|
'ps'
|
|
169
168
|
else
|
|
170
|
-
|
|
169
|
+
raise ArgumentError, message('unrecognized command', hint: command)
|
|
171
170
|
end
|
|
172
171
|
cmd << '-a' if has_value!(args, 'a', 'all') && command != 'network'
|
|
173
172
|
data = VAL_DOCKER[:ls][command.to_sym]
|
|
@@ -228,19 +227,20 @@ module Squared
|
|
|
228
227
|
format_desc action, flag, "service/:,command#{'?' unless flag == :exec}/::,args*,opts*"
|
|
229
228
|
task flag, [:service] do |_, args|
|
|
230
229
|
service = param_guard(action, flag, args: args, key: :service)
|
|
231
|
-
|
|
230
|
+
compose_(flag, args.extras, service: service)
|
|
232
231
|
end
|
|
233
232
|
when :service
|
|
234
233
|
cmds = %w[down kill pause restart rm start stop top unpause watch].freeze
|
|
235
234
|
format_desc(action, flag, cmds, arg: nil, after: 'name+|:')
|
|
236
235
|
task flag, [:command] do |_, args|
|
|
237
|
-
|
|
238
|
-
|
|
236
|
+
cmd = param_guard(action, flag, args: args, key: :command)
|
|
237
|
+
raise ArgumentError, message('unrecognized command', hint: cmd) unless cmds.include?(cmd)
|
|
238
|
+
|
|
239
239
|
service = args.extras
|
|
240
240
|
if service.first == ':'
|
|
241
|
-
choice_command flag,
|
|
241
|
+
choice_command flag, cmd
|
|
242
242
|
else
|
|
243
|
-
|
|
243
|
+
compose_(flag, [cmd], service: service.empty? || service)
|
|
244
244
|
end
|
|
245
245
|
end
|
|
246
246
|
when :publish
|
|
@@ -248,12 +248,12 @@ module Squared
|
|
|
248
248
|
|
|
249
249
|
format_desc action, flag, 'tag?,repository?,opts*'
|
|
250
250
|
task flag, [:tag] do |_, args|
|
|
251
|
-
|
|
251
|
+
compose_ flag, args.to_a
|
|
252
252
|
end
|
|
253
253
|
else
|
|
254
254
|
format_desc action, flag, 'opts*,service*|:'
|
|
255
255
|
task flag do |_, args|
|
|
256
|
-
|
|
256
|
+
compose_(flag, args.to_a, multiple: true)
|
|
257
257
|
end
|
|
258
258
|
end
|
|
259
259
|
when 'container'
|
|
@@ -278,7 +278,7 @@ module Squared
|
|
|
278
278
|
end
|
|
279
279
|
end
|
|
280
280
|
else
|
|
281
|
-
format_desc action, flag, "opts*,id/name#{flag == :update
|
|
281
|
+
format_desc action, flag, "opts*,id/name#{flag == :update ? '+' : '*'}"
|
|
282
282
|
task flag do |_, args|
|
|
283
283
|
container flag, args.to_a
|
|
284
284
|
end
|
|
@@ -289,7 +289,7 @@ module Squared
|
|
|
289
289
|
next unless @registry
|
|
290
290
|
|
|
291
291
|
format_desc action, flag, 'tag?,registry/username?,opts*'
|
|
292
|
-
task flag do |_, args|
|
|
292
|
+
task flag, [:tag] do |_, args|
|
|
293
293
|
image flag, args.to_a
|
|
294
294
|
end
|
|
295
295
|
when :pull
|
|
@@ -298,11 +298,6 @@ module Squared
|
|
|
298
298
|
id = param_guard(action, flag, args: args, key: :tag)
|
|
299
299
|
image(flag, args.extras, id: id)
|
|
300
300
|
end
|
|
301
|
-
when :inspect
|
|
302
|
-
format_desc action, flag, 'opts*,id+'
|
|
303
|
-
task flag do |_, args|
|
|
304
|
-
image flag, args.to_a
|
|
305
|
-
end
|
|
306
301
|
else
|
|
307
302
|
format_desc(action, flag, case flag
|
|
308
303
|
when :rm, :save then 'id,opts*'
|
|
@@ -406,15 +401,15 @@ module Squared
|
|
|
406
401
|
end
|
|
407
402
|
|
|
408
403
|
def buildx(flag, opts = [], tag: nil, context: nil, from: nil)
|
|
409
|
-
bx = OPT_DOCKER[:buildx]
|
|
410
404
|
if flag == :bake && context&.match?(%r{^["']?(https?|git)://}i)
|
|
411
|
-
shared =
|
|
405
|
+
shared = data[:shared].dup.push('f|file=q')
|
|
412
406
|
shared.delete('f|file=p')
|
|
413
407
|
end
|
|
414
408
|
cmd, opts = docker_session('buildx', opts: opts)
|
|
415
|
-
|
|
409
|
+
data = OPT_DOCKER[:buildx]
|
|
410
|
+
op = OptionPartition.new(opts, data[:common], cmd, project: self, strict: strict?)
|
|
416
411
|
op.append(flag, quote: false)
|
|
417
|
-
.parse(
|
|
412
|
+
.parse(data[flag == :bake ? :bake : :build] + (shared || data[:shared]))
|
|
418
413
|
case flag
|
|
419
414
|
when :build, :context
|
|
420
415
|
append_tag(tag || option('tag', ignore: false) || self.tag)
|
|
@@ -425,10 +420,6 @@ module Squared
|
|
|
425
420
|
end
|
|
426
421
|
when :bake
|
|
427
422
|
append_file(0, index: 3) unless from || op.arg?('f', 'file') || !anypath?(*COMPOSEFILE)
|
|
428
|
-
if op.first == '-'
|
|
429
|
-
op.shift
|
|
430
|
-
op << @output[4] if @output[4]
|
|
431
|
-
end
|
|
432
423
|
unless op.empty?
|
|
433
424
|
if !context && op.size > 1 && exist?(op.last, type: 'd')
|
|
434
425
|
pat = /\btarget\s+"#{Regexp.escape(op.last)}"/
|
|
@@ -445,7 +436,7 @@ module Squared
|
|
|
445
436
|
run(from: from || symjoin('buildx', flag))
|
|
446
437
|
end
|
|
447
438
|
|
|
448
|
-
def
|
|
439
|
+
def compose_(flag, opts = [], id: nil, service: nil, multiple: false)
|
|
449
440
|
from = symjoin 'compose', flag
|
|
450
441
|
if flag == :service
|
|
451
442
|
command = opts.first
|
|
@@ -459,11 +450,10 @@ module Squared
|
|
|
459
450
|
docker_session('compose', command, '--', *service)
|
|
460
451
|
else
|
|
461
452
|
cmd, opts = docker_session('compose', opts: opts)
|
|
462
|
-
|
|
463
|
-
op = OptionPartition.new(opts, cp[:common], cmd, project: self, strict: strict?)
|
|
453
|
+
op = OptionPartition.new(opts, OPT_DOCKER[:compose][:common], cmd, project: self, strict: strict?)
|
|
464
454
|
append_file(filetype, force: flag == :publish) unless op.arg?('f', 'file')
|
|
465
455
|
op << flag
|
|
466
|
-
op.parse(
|
|
456
|
+
op.parse(OPT_DOCKER[:compose].fetch(flag, []))
|
|
467
457
|
if flag == :publish
|
|
468
458
|
id ||= option('tag', ignore: false) || op.shift || tagmain
|
|
469
459
|
registry ||= option('registry') || op.shift || @oci
|
|
@@ -483,22 +473,21 @@ module Squared
|
|
|
483
473
|
op.concat(service) if service
|
|
484
474
|
op.append(delim: true, escape: true, strip: /^:/)
|
|
485
475
|
else
|
|
486
|
-
|
|
476
|
+
raise ArgumentError, message('no service was selected', hint: flag) unless service
|
|
477
|
+
|
|
487
478
|
append_command(flag, service, op.extras, prompt: '::')
|
|
488
479
|
end
|
|
489
480
|
end
|
|
490
481
|
end
|
|
491
482
|
run(from: from)
|
|
492
483
|
end
|
|
493
|
-
alias compose_ compose!
|
|
494
484
|
|
|
495
485
|
def container(flag, opts = [], id: nil)
|
|
496
486
|
cmd, opts = docker_session('container', flag, opts: opts)
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
list =
|
|
500
|
-
list +=
|
|
501
|
-
list += ct[:update] if rc ||= flag == :create
|
|
487
|
+
data = OPT_DOCKER[:container]
|
|
488
|
+
list = data.fetch(flag, [])
|
|
489
|
+
list += data[:create] if (rc = flag == :run)
|
|
490
|
+
list += data[:update] if rc ||= flag == :create
|
|
502
491
|
op = OptionPartition.new(opts, list, cmd, project: self, strict: strict?, args: rc || flag == :exec)
|
|
503
492
|
from = symjoin 'container', flag
|
|
504
493
|
case flag
|
|
@@ -515,7 +504,7 @@ module Squared
|
|
|
515
504
|
when 'bind', 'volume', 'image', 'tmpfs'
|
|
516
505
|
type = v
|
|
517
506
|
else
|
|
518
|
-
|
|
507
|
+
raise TypeError, message('unknown', v || "''", hint: flag)
|
|
519
508
|
end
|
|
520
509
|
elsif all.include?(k)
|
|
521
510
|
unless type
|
|
@@ -527,43 +516,34 @@ module Squared
|
|
|
527
516
|
end
|
|
528
517
|
end
|
|
529
518
|
case k
|
|
530
|
-
when 'readonly', 'ro'
|
|
531
|
-
out << k
|
|
519
|
+
when 'readonly', 'ro'
|
|
520
|
+
out << k
|
|
532
521
|
next
|
|
533
|
-
when 'source', 'src', 'destination', 'dst', 'target', 'volume-subpath', 'image-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
if type == 'bind'
|
|
538
|
-
v = basepath v
|
|
539
|
-
elsif type == 'tmpfs'
|
|
540
|
-
next
|
|
541
|
-
end
|
|
542
|
-
when 'destination', 'dst', 'target'
|
|
543
|
-
unless v.start_with?('/')
|
|
544
|
-
print_error(Logger::ERROR, "path is not absolute: #{v}", subject: from, hint: k)
|
|
545
|
-
next
|
|
546
|
-
end
|
|
547
|
-
end
|
|
522
|
+
when 'source', 'src', 'destination', 'dst', 'target', 'volume-subpath', 'image-path'
|
|
523
|
+
raise ArgumentError, message('no path value', k, hint: flag) unless v
|
|
524
|
+
|
|
525
|
+
v = basepath v
|
|
548
526
|
v = shell_quote(v, option: false, force: false) if q == ''
|
|
549
527
|
end
|
|
550
528
|
out << "#{k}=#{q}#{v}#{q}"
|
|
551
529
|
elsif !silent?
|
|
552
|
-
|
|
530
|
+
log_message('unrecognized option', subject: from, hint: k)
|
|
553
531
|
end
|
|
554
532
|
end
|
|
555
|
-
|
|
556
|
-
|
|
533
|
+
raise TypeError, message('none specified', hint: flag) unless type
|
|
534
|
+
|
|
535
|
+
cmd << "--mount type=#{type},#{args.join(',')}"
|
|
557
536
|
end
|
|
558
537
|
end
|
|
559
538
|
append_command(flag, id || tagmain, op.extras)
|
|
560
539
|
when :update
|
|
561
|
-
|
|
540
|
+
raise ArgumentError, message('missing container', hint: flag) if op.empty?
|
|
541
|
+
|
|
562
542
|
op.append(escape: true, strip: /^:/)
|
|
563
543
|
when :commit
|
|
564
544
|
latest = op.shift || tagmain
|
|
565
|
-
|
|
566
|
-
|
|
545
|
+
cmd << id << latest
|
|
546
|
+
raise ArgumentError, message('unrecognized args', op.join(', '), hint: flag) unless op.empty?
|
|
567
547
|
return unless confirm_command(cmd.to_s, title: from, target: id, as: latest)
|
|
568
548
|
|
|
569
549
|
registry = option('registry') || @registry
|
|
@@ -583,8 +563,10 @@ module Squared
|
|
|
583
563
|
else
|
|
584
564
|
if op.empty?
|
|
585
565
|
ps, status, no = filter_ps flag, from
|
|
586
|
-
|
|
587
|
-
list_image(flag, ps, no: no, hint: status,
|
|
566
|
+
cmd << '--no-stream' if flag == :stats
|
|
567
|
+
list_image(flag, ps, no: no, hint: status, multiple: flag != :attach, from: from) do |img|
|
|
568
|
+
run(cmd.temp(img), from: from)
|
|
569
|
+
end
|
|
588
570
|
return
|
|
589
571
|
end
|
|
590
572
|
op.append(escape: true, strip: /^:/)
|
|
@@ -645,7 +627,7 @@ module Squared
|
|
|
645
627
|
break
|
|
646
628
|
end
|
|
647
629
|
end
|
|
648
|
-
|
|
630
|
+
raise ArgumentError, message('target not specified', hint: flag) unless found
|
|
649
631
|
when :pull
|
|
650
632
|
if !id
|
|
651
633
|
id = tagmain
|
|
@@ -656,24 +638,22 @@ module Squared
|
|
|
656
638
|
registry = op.shift
|
|
657
639
|
registry ||= option('registry') || @registry unless id.include?('/')
|
|
658
640
|
end
|
|
659
|
-
|
|
641
|
+
cmd << shell_quote(tagjoin(registry, id))
|
|
660
642
|
when :push
|
|
661
643
|
id ||= option('tag', ignore: false) || op.shift || tagmain
|
|
662
644
|
registry ||= option('registry') || op.shift || @registry
|
|
663
645
|
emptyargs op, flag
|
|
664
|
-
|
|
646
|
+
raise ArgumentError, message('username/registry not specified', hint: flag) unless registry
|
|
647
|
+
|
|
665
648
|
uri = shell_quote tagjoin(registry, id)
|
|
666
649
|
op << uri
|
|
667
|
-
img = docker_output 'image tag', id, uri
|
|
650
|
+
img = docker_output 'image', 'tag', id, uri
|
|
668
651
|
return unless confirm_command(img.to_s, cmd.to_s, target: id, as: registry, title: from)
|
|
669
652
|
|
|
670
653
|
@session = img
|
|
671
654
|
sync = false
|
|
672
655
|
exception ||= true
|
|
673
656
|
banner = false
|
|
674
|
-
when :inspect
|
|
675
|
-
raise_error ArgumentError, 'missing image', hint: flag if op.empty?
|
|
676
|
-
op.append(escape: true, strip: /^:/)
|
|
677
657
|
end
|
|
678
658
|
success?(run(sync: sync, exception: exception, banner: banner, from: from), flag == :tag || flag == :save)
|
|
679
659
|
end
|
|
@@ -755,36 +735,22 @@ module Squared
|
|
|
755
735
|
session('docker', *cmd, main: false, options: false, **kwargs)
|
|
756
736
|
end
|
|
757
737
|
|
|
758
|
-
def append_command(flag,
|
|
759
|
-
if list.delete(prompt)
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
738
|
+
def append_command(flag, val, list, target: @session, prompt: ':')
|
|
739
|
+
list << if list.delete(prompt)
|
|
740
|
+
readline('Enter command [args]', force: flag == :exec)
|
|
741
|
+
else
|
|
742
|
+
env('DOCKER_ARGS')
|
|
743
|
+
end
|
|
764
744
|
case flag
|
|
765
745
|
when :run
|
|
766
746
|
unless session_arg?('name', target: target)
|
|
767
747
|
target << basic_option('name', dnsname("#{name}_%s" % rand_s(6)))
|
|
768
748
|
end
|
|
769
749
|
when :exec
|
|
770
|
-
|
|
771
|
-
end
|
|
772
|
-
target << id
|
|
773
|
-
case list.first
|
|
774
|
-
when '--'
|
|
775
|
-
target.merge(list.drop(1))
|
|
776
|
-
when /\A(--|&&)(\s|\z)/
|
|
777
|
-
target.merge(list)
|
|
778
|
-
else
|
|
779
|
-
target << list.shift
|
|
780
|
-
unless list.empty?
|
|
781
|
-
if list.first.start_with?('-')
|
|
782
|
-
target.merge(list)
|
|
783
|
-
else
|
|
784
|
-
target << list.join(' && ')
|
|
785
|
-
end
|
|
786
|
-
end
|
|
750
|
+
raise ArgumentError, message('nothing to execute', hint: flag) if list.empty?
|
|
787
751
|
end
|
|
752
|
+
target << val << list.shift
|
|
753
|
+
target << list.join(' && ') unless list.empty?
|
|
788
754
|
end
|
|
789
755
|
|
|
790
756
|
def append_file(type, target: @session, index: 2, force: false)
|
|
@@ -835,7 +801,7 @@ module Squared
|
|
|
835
801
|
%w[running paused exited]
|
|
836
802
|
when :unpause
|
|
837
803
|
%w[paused]
|
|
838
|
-
when :top, :stats, :watch
|
|
804
|
+
when :top, :stats, :watch, :attach
|
|
839
805
|
%w[running]
|
|
840
806
|
when :kill
|
|
841
807
|
no = true
|
|
@@ -851,19 +817,20 @@ module Squared
|
|
|
851
817
|
[cmd, status, no]
|
|
852
818
|
end
|
|
853
819
|
|
|
854
|
-
def list_image(flag, cmd = docker_output('image ls -a'), filter: nil, hint: nil, no: true,
|
|
820
|
+
def list_image(flag, cmd = docker_output('image ls -a'), filter: nil, hint: nil, no: true, multiple: true,
|
|
821
|
+
from: nil)
|
|
855
822
|
pwd_set(from: from) do
|
|
856
823
|
index = 1
|
|
857
824
|
all = option('all', prefix: 'docker')
|
|
858
|
-
y = from
|
|
825
|
+
y = from == :'image:rm' && option('y', prefix: 'docker')
|
|
859
826
|
filter = env('DOCKER_FILTER', filter).to_s
|
|
860
827
|
pat = if OptionPartition.pattern?(filter)
|
|
861
828
|
Regexp.new(filter)
|
|
862
829
|
elsif filter.match?(/[:_-]$/)
|
|
863
830
|
/\b#{Regexp.escape(filter)}/
|
|
864
831
|
else
|
|
865
|
-
filter = filter.empty? ? '(
|
|
866
|
-
/\b(
|
|
832
|
+
filter = filter.empty? ? '([:_-]|$)' : "[:_-]#{filter}"
|
|
833
|
+
/\b(#{dnsname(name)}|#{tagname(project)}|#{tagmain.split(':', 2).first})#{filter}/
|
|
867
834
|
end
|
|
868
835
|
IO.popen(cmd.temp('--format=json')).each do |line|
|
|
869
836
|
data = JSON.parse(line)
|
|
@@ -910,6 +877,7 @@ module Squared
|
|
|
910
877
|
puts if printfirst?
|
|
911
878
|
end
|
|
912
879
|
yield id
|
|
880
|
+
break unless multiple
|
|
913
881
|
end
|
|
914
882
|
list_empty(hint: hint || from) if index == 1 && !y
|
|
915
883
|
end
|
|
@@ -996,7 +964,7 @@ module Squared
|
|
|
996
964
|
end
|
|
997
965
|
cmd.merge(Array(out).map { |val| val.split(/\s+/, 2).first })
|
|
998
966
|
cmd << args
|
|
999
|
-
success?(run(cmd
|
|
967
|
+
success?(run(cmd), ctx.start_with?('network', 'tag', 'save'))
|
|
1000
968
|
end
|
|
1001
969
|
|
|
1002
970
|
def filetype(val = dockerfile)
|
|
@@ -1043,7 +1011,7 @@ module Squared
|
|
|
1043
1011
|
end
|
|
1044
1012
|
|
|
1045
1013
|
def emptyargs(list, hint = nil)
|
|
1046
|
-
|
|
1014
|
+
raise ArgumentError, message('unrecognized args', list.join(', '), hint: hint) unless list.empty?
|
|
1047
1015
|
end
|
|
1048
1016
|
|
|
1049
1017
|
def anypath?(*args)
|