squared 0.6.2 → 0.6.3
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 +40 -0
- data/README.md +23 -13
- data/lib/squared/common/base.rb +2 -2
- data/lib/squared/common/format.rb +39 -32
- data/lib/squared/common/prompt.rb +6 -4
- data/lib/squared/common/shell.rb +4 -4
- data/lib/squared/config.rb +6 -7
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +72 -23
- data/lib/squared/workspace/project/base.rb +145 -83
- data/lib/squared/workspace/project/docker.rb +15 -15
- data/lib/squared/workspace/project/git.rb +74 -27
- data/lib/squared/workspace/project/node.rb +211 -109
- data/lib/squared/workspace/project/python.rb +9 -9
- data/lib/squared/workspace/project/ruby.rb +29 -34
- data/lib/squared/workspace/project/support/class.rb +36 -652
- data/lib/squared/workspace/project/support/optionpartition.rb +641 -0
- data/lib/squared/workspace/project.rb +0 -1
- data/lib/squared/workspace/repo.rb +23 -14
- data/lib/squared/workspace/series.rb +10 -8
- data/squared.gemspec +2 -2
- metadata +3 -3
- data/lib/squared/workspace/project/support.rb +0 -3
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
require 'json'
|
|
4
4
|
require 'logger'
|
|
5
5
|
|
|
6
|
+
require_relative 'support/class'
|
|
7
|
+
|
|
6
8
|
module Squared
|
|
7
9
|
module Workspace
|
|
8
10
|
module Project
|
|
@@ -109,11 +111,11 @@ module Squared
|
|
|
109
111
|
|
|
110
112
|
subtasks({
|
|
111
113
|
'graph' => %i[run print].freeze,
|
|
112
|
-
'unpack' => %i[zip gz tar ext]
|
|
114
|
+
'unpack' => %i[zip gz tar ext],
|
|
113
115
|
'asdf' => %i[set exec current update latest where reshim]
|
|
114
116
|
})
|
|
115
117
|
|
|
116
|
-
attr_reader :name, :project, :workspace, :path, :theme, :group, :parent, :dependfile,
|
|
118
|
+
attr_reader :name, :project, :workspace, :path, :theme, :group, :parent, :children, :dependfile,
|
|
117
119
|
:exception, :pipe, :verbose, :global
|
|
118
120
|
|
|
119
121
|
def initialize(workspace, path, name, *, group: nil, first: {}, last: {}, error: {}, common: ARG[:COMMON],
|
|
@@ -380,11 +382,7 @@ module Squared
|
|
|
380
382
|
if flag == :run
|
|
381
383
|
graph args
|
|
382
384
|
else
|
|
383
|
-
out
|
|
384
|
-
out.map! do |val|
|
|
385
|
-
n = done.index { |proj| val.match?(/ #{Regexp.escape(proj.name)}(?:@\d|\z)/) }
|
|
386
|
-
n ? val.subhint(n.succ) : val
|
|
387
|
-
end
|
|
385
|
+
out = graph(args, out: [], order: {})
|
|
388
386
|
emphasize(out, title: path, right: true, border: borderstyle, sub: [
|
|
389
387
|
opt_style(theme[:header], /\A(#{Regexp.escape(path.to_s)})(.*)\z/),
|
|
390
388
|
opt_style(theme[:active], /\A(#{Regexp.escape(name)})(.*)\z/),
|
|
@@ -491,7 +489,7 @@ module Squared
|
|
|
491
489
|
proj = self
|
|
492
490
|
instance_eval(&blk) if block_given?
|
|
493
491
|
end
|
|
494
|
-
|
|
492
|
+
children << proj
|
|
495
493
|
end
|
|
496
494
|
self
|
|
497
495
|
end
|
|
@@ -618,7 +616,7 @@ module Squared
|
|
|
618
616
|
end
|
|
619
617
|
|
|
620
618
|
def doc(*, sync: invoked_sync?('doc'), **)
|
|
621
|
-
run_b(@doc, sync: sync, banner: from_base?('doc') ? verbose? :
|
|
619
|
+
run_b(@doc, sync: sync, banner: from_base?('doc') ? verbose? : !silent?, from: :doc)
|
|
622
620
|
end
|
|
623
621
|
|
|
624
622
|
def lint(*, sync: invoked_sync?('lint'), **)
|
|
@@ -659,7 +657,7 @@ module Squared
|
|
|
659
657
|
entry = basepath(val = val.to_s)
|
|
660
658
|
if entry.directory? && val.match?(%r{[\\/]\z})
|
|
661
659
|
log&.warn "rm -rf #{entry}"
|
|
662
|
-
rm_rf(entry, verbose:
|
|
660
|
+
rm_rf(entry, verbose: !silent?)
|
|
663
661
|
else
|
|
664
662
|
log&.warn "rm #{entry}"
|
|
665
663
|
(val.include?('*') ? Dir[entry] : [entry]).each do |file|
|
|
@@ -678,7 +676,7 @@ module Squared
|
|
|
678
676
|
on :last, :clean unless pass
|
|
679
677
|
end
|
|
680
678
|
|
|
681
|
-
def graph(start = [], tasks = nil, *, sync: invoked_sync?('graph'), pass: [], out: nil, **)
|
|
679
|
+
def graph(start = [], tasks = nil, *, sync: invoked_sync?('graph'), pass: [], out: nil, order: nil, **)
|
|
682
680
|
env('GRAPH', strict: true) do |val|
|
|
683
681
|
tasks ||= []
|
|
684
682
|
split_escape(val) do |task|
|
|
@@ -696,12 +694,19 @@ module Squared
|
|
|
696
694
|
data[name] << self
|
|
697
695
|
on :first, :graph
|
|
698
696
|
end
|
|
699
|
-
ret = graph_branch(self, data, tasks, out, sync: sync, pass: pass)
|
|
697
|
+
ret = graph_branch(self, data, tasks, out, sync: sync, pass: pass, order: order)
|
|
700
698
|
rescue StandardError => e
|
|
701
699
|
on_error(e, :graph, exception: true)
|
|
702
700
|
else
|
|
703
701
|
if out
|
|
704
|
-
|
|
702
|
+
if order
|
|
703
|
+
out.map! do |val|
|
|
704
|
+
name = ret.find { |proj| val.match?(/ #{Regexp.escape(proj.name)}(?:@\d|\z)/) }&.name
|
|
705
|
+
(n = name && order[name]) ? val.subhint(n.succ) : val
|
|
706
|
+
end
|
|
707
|
+
else
|
|
708
|
+
[out, ret]
|
|
709
|
+
end
|
|
705
710
|
else
|
|
706
711
|
on :last, :graph
|
|
707
712
|
end
|
|
@@ -770,7 +775,7 @@ module Squared
|
|
|
770
775
|
break uri = url if data
|
|
771
776
|
end
|
|
772
777
|
unless data && (ext ||= URI.decode_www_form_component(URI.parse(uri).path[/\.([\w%]+)(?:\?|\z)/, 1]))
|
|
773
|
-
raise_error(data ? TypeError : RuntimeError, "no content#{
|
|
778
|
+
raise_error(data ? TypeError : RuntimeError, "no content#{' type' if data}", hint: uri)
|
|
774
779
|
end
|
|
775
780
|
end
|
|
776
781
|
ext = ext.downcase
|
|
@@ -800,7 +805,7 @@ module Squared
|
|
|
800
805
|
when 'zip', 'aar'
|
|
801
806
|
session 'unzip', shell_quote(file), quote_option('d', target)
|
|
802
807
|
when 'tar', /\A(?:t|tar\.)?[gx]z\z/
|
|
803
|
-
flags = +(
|
|
808
|
+
flags = +(silent? ? '' : 'v')
|
|
804
809
|
if ext.end_with?('gz')
|
|
805
810
|
flags += 'z'
|
|
806
811
|
elsif ext.end_with?('xz')
|
|
@@ -865,7 +870,7 @@ module Squared
|
|
|
865
870
|
cmd << name
|
|
866
871
|
else
|
|
867
872
|
cmd << name
|
|
868
|
-
banner = flag == :
|
|
873
|
+
banner = false if flag == :latest || flag == :where
|
|
869
874
|
end
|
|
870
875
|
success?(run(banner: banner, from: :"asdf:#{flag}"), flag == :set || flag == :reshim)
|
|
871
876
|
end
|
|
@@ -918,16 +923,16 @@ module Squared
|
|
|
918
923
|
|
|
919
924
|
cmd = cmd.target if cmd.is_a?(OptionPartition)
|
|
920
925
|
if interactive && sync && (!@session || !option('y'))
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
exit 1 unless confirm_basic("#{
|
|
926
|
+
msg, y, h = case interactive
|
|
927
|
+
when Array
|
|
928
|
+
interactive
|
|
929
|
+
when String
|
|
930
|
+
[interactive, 'N']
|
|
931
|
+
else
|
|
932
|
+
%w[Run Y]
|
|
933
|
+
end
|
|
934
|
+
msg = "#{msg} #{sub_style(h, theme[:active])}" if h
|
|
935
|
+
exit 1 unless confirm_basic("#{msg}?", cmd, y)
|
|
931
936
|
end
|
|
932
937
|
cmd = session_done cmd
|
|
933
938
|
log&.info cmd
|
|
@@ -1085,6 +1090,10 @@ module Squared
|
|
|
1085
1090
|
@prod != false && workspace.prod?(pat: @prod, **scriptargs)
|
|
1086
1091
|
end
|
|
1087
1092
|
|
|
1093
|
+
def empty?
|
|
1094
|
+
children.empty?
|
|
1095
|
+
end
|
|
1096
|
+
|
|
1088
1097
|
def exclude?(*refs)
|
|
1089
1098
|
!@exclude.empty? && has_value?(@exclude, refs.flatten)
|
|
1090
1099
|
end
|
|
@@ -1159,7 +1168,7 @@ module Squared
|
|
|
1159
1168
|
log_console(*args, pipe: kwargs[:pipe] || pipe)
|
|
1160
1169
|
end
|
|
1161
1170
|
|
|
1162
|
-
def run_s(*cmd, sync: true, banner:
|
|
1171
|
+
def run_s(*cmd, sync: true, banner: !silent?, from: nil, **kwargs)
|
|
1163
1172
|
cmd.flatten!
|
|
1164
1173
|
case cmd.last
|
|
1165
1174
|
when Hash, TrueClass, FalseClass
|
|
@@ -1204,11 +1213,11 @@ module Squared
|
|
|
1204
1213
|
end
|
|
1205
1214
|
end
|
|
1206
1215
|
|
|
1207
|
-
def graph_branch(target, data, tasks = nil, out = nil, sync: true, pass: [], done: [], depth: 0,
|
|
1216
|
+
def graph_branch(target, data, tasks = nil, out = nil, sync: true, pass: [], done: [], order: nil, depth: 0,
|
|
1208
1217
|
single: false, last: false, context: nil)
|
|
1209
|
-
tag = ->(proj) { "#{proj.name}#{
|
|
1218
|
+
tag = ->(proj) { "#{proj.name}#{"@#{proj.version}" if SEM_VER.match?(proj.version)}" }
|
|
1210
1219
|
script = ->(proj) { workspace.script_get(:graph, group: proj.group, ref: proj.allref)&.fetch(:graph, nil) }
|
|
1211
|
-
|
|
1220
|
+
uniq = lambda do |name|
|
|
1212
1221
|
next [] unless (ret = data[name])
|
|
1213
1222
|
|
|
1214
1223
|
ret.dup.each do |proj|
|
|
@@ -1219,7 +1228,7 @@ module Squared
|
|
|
1219
1228
|
ret
|
|
1220
1229
|
end
|
|
1221
1230
|
if depth == 0
|
|
1222
|
-
items =
|
|
1231
|
+
items = uniq.call(target.name) - done
|
|
1223
1232
|
single = items.size == 1
|
|
1224
1233
|
else
|
|
1225
1234
|
items = data[target.name] - done
|
|
@@ -1243,7 +1252,7 @@ module Squared
|
|
|
1243
1252
|
items.each_with_index do |proj, i|
|
|
1244
1253
|
next if done.include?(proj)
|
|
1245
1254
|
|
|
1246
|
-
t =
|
|
1255
|
+
t = uniq.call(name = proj.name)
|
|
1247
1256
|
j = if out
|
|
1248
1257
|
if i == items.size.pred || (post = items[i.succ..-1] - done).empty?
|
|
1249
1258
|
true
|
|
@@ -1252,10 +1261,41 @@ module Squared
|
|
|
1252
1261
|
end
|
|
1253
1262
|
end
|
|
1254
1263
|
unless target.name == name || (none = (t - done).empty?)
|
|
1255
|
-
graph_branch(proj, data, tasks, out, sync: sync, pass: pass, done: done, depth: depth.succ,
|
|
1264
|
+
graph_branch(proj, data, tasks, out, sync: sync, pass: pass, done: done, order: order, depth: depth.succ,
|
|
1256
1265
|
single: single, last: j == true, context: target)
|
|
1257
1266
|
end
|
|
1258
|
-
if
|
|
1267
|
+
if out
|
|
1268
|
+
if none
|
|
1269
|
+
a, b, c, d = ARG[:GRAPH]
|
|
1270
|
+
out << if depth == 0
|
|
1271
|
+
"#{i == items.size.pred ? d : c}#{b * 4} #{tag.call(proj)}"
|
|
1272
|
+
else
|
|
1273
|
+
s = +''
|
|
1274
|
+
k = 0
|
|
1275
|
+
final = data.keys.last
|
|
1276
|
+
while k < depth
|
|
1277
|
+
indent = k > 0 ? ((last && !j) || (j && k == depth.pred) || single) : j && last && depth == 1
|
|
1278
|
+
s += "#{indent || (last && data[final].last == context) ? ' ' : a} "
|
|
1279
|
+
k += 1
|
|
1280
|
+
end
|
|
1281
|
+
s += "#{j ? d : c}#{b * 3} #{tag.call(proj)}"
|
|
1282
|
+
end
|
|
1283
|
+
end
|
|
1284
|
+
if order
|
|
1285
|
+
n = order.size
|
|
1286
|
+
order[name] ||= if proj.parent
|
|
1287
|
+
if order[s = proj.parent.name]
|
|
1288
|
+
order[s] += 1
|
|
1289
|
+
n.pred
|
|
1290
|
+
else
|
|
1291
|
+
order[s] = n.succ
|
|
1292
|
+
n
|
|
1293
|
+
end
|
|
1294
|
+
else
|
|
1295
|
+
n
|
|
1296
|
+
end
|
|
1297
|
+
end
|
|
1298
|
+
else
|
|
1259
1299
|
(tasks || (subtasks = script.call(proj)) || (dev? ? %w[build copy] : %w[depend build])).each do |meth|
|
|
1260
1300
|
next if pass.include?(meth)
|
|
1261
1301
|
|
|
@@ -1271,21 +1311,6 @@ module Squared
|
|
|
1271
1311
|
proj.__send__(meth.to_sym, sync: sync)
|
|
1272
1312
|
end
|
|
1273
1313
|
end
|
|
1274
|
-
elsif none
|
|
1275
|
-
a, b, c, d = ARG[:GRAPH]
|
|
1276
|
-
out << if depth == 0
|
|
1277
|
-
"#{i == items.size.pred ? d : c}#{b * 4} #{tag.call(proj)}"
|
|
1278
|
-
else
|
|
1279
|
-
s = ''.dup
|
|
1280
|
-
k = 0
|
|
1281
|
-
final = data.keys.last
|
|
1282
|
-
while k < depth
|
|
1283
|
-
indent = k > 0 ? ((last && !j) || (j && k == depth.pred) || single) : j && last && depth == 1
|
|
1284
|
-
s += "#{indent || (last && data[final].last == context) ? ' ' : a} "
|
|
1285
|
-
k += 1
|
|
1286
|
-
end
|
|
1287
|
-
s + "#{j ? d : c}#{b * 3} #{tag.call(proj)}"
|
|
1288
|
-
end
|
|
1289
1314
|
end
|
|
1290
1315
|
done << proj
|
|
1291
1316
|
end
|
|
@@ -1301,16 +1326,22 @@ module Squared
|
|
|
1301
1326
|
obj.enabled? ? [obj] : []
|
|
1302
1327
|
else
|
|
1303
1328
|
workspace.find(group: val, ref: val.to_sym)
|
|
1329
|
+
end.sort do |a, b|
|
|
1330
|
+
if a.parent == b
|
|
1331
|
+
-1
|
|
1332
|
+
else
|
|
1333
|
+
b.parent == a ? 1 : 0
|
|
1334
|
+
end
|
|
1304
1335
|
end.each do |proj|
|
|
1305
1336
|
next if pass.include?(name = proj.name)
|
|
1306
1337
|
|
|
1307
1338
|
if proj.graph? && !data.key?(name) && !root.include?(name)
|
|
1308
1339
|
graph_collect(proj, data: data, pass: pass, root: root + [name, target.name])
|
|
1309
1340
|
end
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1341
|
+
next if (objs = data.fetch(name, [])).include?(target)
|
|
1342
|
+
|
|
1343
|
+
deps << proj
|
|
1344
|
+
deps.concat(objs)
|
|
1314
1345
|
end
|
|
1315
1346
|
end
|
|
1316
1347
|
deps.uniq!
|
|
@@ -1346,11 +1377,13 @@ module Squared
|
|
|
1346
1377
|
ENV[name] || ENV.fetch(key, '')
|
|
1347
1378
|
end
|
|
1348
1379
|
if !equals.nil?
|
|
1349
|
-
ret = ret ==
|
|
1380
|
+
ret = Array(equals).any? { |val| ret == val.to_s }
|
|
1350
1381
|
elsif ret.empty? || (ignore && Array(ignore).any? { |val| ret == val.to_s })
|
|
1351
1382
|
ret = default
|
|
1352
1383
|
end
|
|
1353
|
-
block_given? && !ret.nil?
|
|
1384
|
+
return yield ret if block_given? && !ret.nil?
|
|
1385
|
+
|
|
1386
|
+
ret
|
|
1354
1387
|
end
|
|
1355
1388
|
|
|
1356
1389
|
def session(*cmd, prefix: cmd.first, main: true, path: true, options: true)
|
|
@@ -1364,11 +1397,13 @@ module Squared
|
|
|
1364
1397
|
if val.start_with?('-')
|
|
1365
1398
|
ret.merge(shell_parse(val))
|
|
1366
1399
|
else
|
|
1367
|
-
split_escape(val) { |opt| ret.last(fill_option(opt), /\A(--?[
|
|
1400
|
+
split_escape(val) { |opt| ret.last(fill_option(opt), /\A(--?[^=\s-][^=\s]*)[=\s].+\z/m) }
|
|
1368
1401
|
end
|
|
1369
1402
|
end
|
|
1370
1403
|
end
|
|
1371
|
-
|
|
1404
|
+
return ret unless main
|
|
1405
|
+
|
|
1406
|
+
@session = ret
|
|
1372
1407
|
end
|
|
1373
1408
|
|
|
1374
1409
|
def session_output(*cmd, **kwargs)
|
|
@@ -1497,7 +1532,7 @@ module Squared
|
|
|
1497
1532
|
val
|
|
1498
1533
|
end
|
|
1499
1534
|
end
|
|
1500
|
-
(lines << sub_style(ARG[:BORDER][1] * n,
|
|
1535
|
+
(lines << sub_style(ARG[:BORDER][1] * n, border)).join("\n")
|
|
1501
1536
|
end
|
|
1502
1537
|
|
|
1503
1538
|
def print_footer(*lines, sub: nil, reverse: false, right: false, border: borderstyle, **)
|
|
@@ -1505,30 +1540,32 @@ module Squared
|
|
|
1505
1540
|
sub = as_a sub
|
|
1506
1541
|
lines.map! do |val|
|
|
1507
1542
|
s = right ? val.rjust(n) : val.ljust(n)
|
|
1508
|
-
sub.each { |h|
|
|
1543
|
+
sub.each { |h| sub_style!(s, **h) }
|
|
1509
1544
|
s
|
|
1510
1545
|
end
|
|
1511
|
-
[sub_style(ARG[:BORDER][1] * n,
|
|
1512
|
-
|
|
1513
|
-
|
|
1546
|
+
[sub_style(ARG[:BORDER][1] * n, border)].concat(lines)
|
|
1547
|
+
.tap { |ret| ret.reverse! if reverse }
|
|
1548
|
+
.join("\n")
|
|
1514
1549
|
end
|
|
1515
1550
|
|
|
1516
1551
|
def print_status(*args, from: nil, **kwargs)
|
|
1517
|
-
return if stdin?
|
|
1552
|
+
return if stdin? || silent?
|
|
1518
1553
|
|
|
1519
1554
|
case from
|
|
1520
1555
|
when :outdated
|
|
1521
1556
|
out = print_footer("major #{args[0]} / minor #{args[1]} / patch #{args[2]}", right: true).split("\n")
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
puts out
|
|
1557
|
+
sub_style!(out[1], **opt_style(theme[:major], /^( +major )(\d+)(.+)$/, 2))
|
|
1558
|
+
sub_style!(out[1], **opt_style(theme[:active], /^(.+)(minor )(\d+)(.+)$/, 3))
|
|
1559
|
+
sub_style!(out[1], **opt_style(theme[:current], /^(.+)(patch )(\d+)(.+)$/, 3)) if theme[:current]
|
|
1526
1560
|
when :completed
|
|
1527
|
-
return unless
|
|
1561
|
+
return unless kwargs[:start]
|
|
1528
1562
|
|
|
1529
|
-
|
|
1530
|
-
|
|
1563
|
+
out = log_message(Logger::INFO, *args, sub_style('completed', theme[:active]),
|
|
1564
|
+
subject: kwargs[:subject], hint: time_format(time_epoch - kwargs[:start]))
|
|
1565
|
+
else
|
|
1566
|
+
return
|
|
1531
1567
|
end
|
|
1568
|
+
puts out
|
|
1532
1569
|
end
|
|
1533
1570
|
|
|
1534
1571
|
def format_desc(action, flag, opts = nil, **kwargs)
|
|
@@ -1621,7 +1658,7 @@ module Squared
|
|
|
1621
1658
|
end
|
|
1622
1659
|
|
|
1623
1660
|
def empty_status(msg, title, obj, always: false)
|
|
1624
|
-
"#{msg}#{!always && (!obj || obj == 0 || obj.to_s.empty?)
|
|
1661
|
+
"#{msg}#{message(hint: message(title, obj.to_s)) unless !always && (!obj || obj == 0 || obj.to_s.empty?)}"
|
|
1625
1662
|
end
|
|
1626
1663
|
|
|
1627
1664
|
def append_repeat(flag, opts, target: @session)
|
|
@@ -1828,22 +1865,37 @@ module Squared
|
|
|
1828
1865
|
end
|
|
1829
1866
|
|
|
1830
1867
|
def confirm_basic(msg, target, default = 'Y', style: :inline, **kwargs)
|
|
1831
|
-
confirm("#{msg} [#{sub_style(target.to_s,
|
|
1868
|
+
confirm("#{msg} [#{sub_style(target.to_s, theme[style])}]", default, **kwargs)
|
|
1832
1869
|
end
|
|
1833
1870
|
|
|
1834
|
-
def confirm_outdated(pkg, ver, rev, cur = nil, lock: false, col1: 0,
|
|
1835
|
-
|
|
1871
|
+
def confirm_outdated(pkg, ver, rev, cur = nil, lock: false, col0: 0, col1: 0, col2: nil, col3: 0, col4: 0,
|
|
1872
|
+
**kwargs)
|
|
1873
|
+
h = sub_style(case rev
|
|
1836
1874
|
when 1
|
|
1837
1875
|
'MAJOR'
|
|
1838
1876
|
when 2
|
|
1839
1877
|
'MINOR'
|
|
1840
1878
|
else
|
|
1841
1879
|
'PATCH'
|
|
1842
|
-
end,
|
|
1843
|
-
|
|
1844
|
-
|
|
1880
|
+
end, (rev == 1 && theme[:major]) || theme[:header])
|
|
1881
|
+
case col0
|
|
1882
|
+
when 0
|
|
1883
|
+
col0 = "#{h}: "
|
|
1884
|
+
when Numeric
|
|
1885
|
+
puts h
|
|
1886
|
+
col0 = ' ' * col0
|
|
1887
|
+
else
|
|
1888
|
+
puts h
|
|
1889
|
+
end
|
|
1890
|
+
b = sub_style pkg.ljust(col1), theme[:inline]
|
|
1891
|
+
cur ||= 'locked' if lock
|
|
1892
|
+
c = if cur
|
|
1893
|
+
cur = cur.ljust(col2 || cur.size.succ)
|
|
1894
|
+
lock ? sub_style(cur, color(:red)) : cur
|
|
1895
|
+
end
|
|
1845
1896
|
d = rev == 1 || lock ? 'N' : 'Y'
|
|
1846
|
-
|
|
1897
|
+
e = "#{col0}#{b}#{c}#{sub_style(col1 > 0 ? ver.ljust(col3) : ver.rjust(ver.size.succ), theme[:inline])}"
|
|
1898
|
+
confirm("#{e}#{col4 > 0 ? ' ' * [col4 - e.stripstyle.size - 1, 2].max : ' '}", d, **kwargs)
|
|
1847
1899
|
end
|
|
1848
1900
|
|
|
1849
1901
|
def choice_index(msg, list, values: nil, accept: nil, series: false, trim: nil, column: nil, multiple: false,
|
|
@@ -1862,12 +1914,12 @@ module Squared
|
|
|
1862
1914
|
ret = ret.first unless multiple
|
|
1863
1915
|
end
|
|
1864
1916
|
if accept
|
|
1865
|
-
hint = Array(ret).map { |val| sub_style(val.to_s,
|
|
1917
|
+
hint = Array(ret).map { |val| sub_style(val.to_s, theme[:inline]) }.join(', ')
|
|
1866
1918
|
accept = Array(accept).map { |val| Array(val) }
|
|
1867
1919
|
ret = Array(ret) if accept.any? { |val| val[1] == true }
|
|
1868
1920
|
loop do
|
|
1869
1921
|
item = accept.first
|
|
1870
|
-
c = confirm("#{item[0]}#{
|
|
1922
|
+
c = confirm("#{item[0]}#{" [#{hint}]" if hint}", item[2] ? 'Y' : 'N')
|
|
1871
1923
|
if item[1] == true
|
|
1872
1924
|
ret << c
|
|
1873
1925
|
elsif !c
|
|
@@ -2197,7 +2249,7 @@ module Squared
|
|
|
2197
2249
|
end
|
|
2198
2250
|
|
|
2199
2251
|
def theme_set(common)
|
|
2200
|
-
@theme = if
|
|
2252
|
+
@theme = if silent?
|
|
2201
2253
|
{}
|
|
2202
2254
|
elsif common
|
|
2203
2255
|
workspace.theme
|
|
@@ -2232,7 +2284,7 @@ module Squared
|
|
|
2232
2284
|
__send__ key
|
|
2233
2285
|
end
|
|
2234
2286
|
end
|
|
2235
|
-
next if (items =
|
|
2287
|
+
next if (items = children.select { |item| item.task_include?(key) }).empty?
|
|
2236
2288
|
|
|
2237
2289
|
ws.task_desc(@desc, action, 'workspace')
|
|
2238
2290
|
task task_join(action, 'workspace') => items.map! { |item| task_join(item.name, action) }
|
|
@@ -2313,7 +2365,13 @@ module Squared
|
|
|
2313
2365
|
else
|
|
2314
2366
|
$?.success?
|
|
2315
2367
|
end.tap do |ret|
|
|
2316
|
-
|
|
2368
|
+
next unless cond.none? { |val| val == false }
|
|
2369
|
+
|
|
2370
|
+
if block_given?
|
|
2371
|
+
yield ret
|
|
2372
|
+
elsif ret && stdout? && banner?
|
|
2373
|
+
print_success
|
|
2374
|
+
end
|
|
2317
2375
|
end
|
|
2318
2376
|
end
|
|
2319
2377
|
|
|
@@ -2337,6 +2395,10 @@ module Squared
|
|
|
2337
2395
|
verbosetype > 1
|
|
2338
2396
|
end
|
|
2339
2397
|
|
|
2398
|
+
def silent?
|
|
2399
|
+
verbosetype == 0
|
|
2400
|
+
end
|
|
2401
|
+
|
|
2340
2402
|
def warning?
|
|
2341
2403
|
workspace.warning
|
|
2342
2404
|
end
|
|
@@ -222,7 +222,7 @@ module Squared
|
|
|
222
222
|
|
|
223
223
|
case flag
|
|
224
224
|
when :exec, :run
|
|
225
|
-
format_desc action, flag, "service|:,command#{flag == :exec
|
|
225
|
+
format_desc action, flag, "service|:,command#{'?' unless flag == :exec}|::,args*,opts*"
|
|
226
226
|
task flag, [:service] do |_, args|
|
|
227
227
|
service = param_guard(action, flag, args: args, key: :service)
|
|
228
228
|
compose!(flag, args.extras, service: service)
|
|
@@ -477,8 +477,8 @@ module Squared
|
|
|
477
477
|
end
|
|
478
478
|
elsif all.include?(k)
|
|
479
479
|
unless type
|
|
480
|
-
VAL_DOCKER[:run].each_pair do |key,
|
|
481
|
-
next unless
|
|
480
|
+
VAL_DOCKER[:run].each_pair do |key, a|
|
|
481
|
+
next unless a.include?(k)
|
|
482
482
|
|
|
483
483
|
type = key.to_s unless key == :common
|
|
484
484
|
break
|
|
@@ -493,7 +493,7 @@ module Squared
|
|
|
493
493
|
v = shell_quote(v, option: false, force: false) if q == ''
|
|
494
494
|
end
|
|
495
495
|
args << "#{k}=#{q + v + q}"
|
|
496
|
-
elsif
|
|
496
|
+
elsif !silent?
|
|
497
497
|
log_message(Logger::INFO, 'unrecognized option', subject: from, hint: k)
|
|
498
498
|
end
|
|
499
499
|
end
|
|
@@ -523,7 +523,7 @@ module Squared
|
|
|
523
523
|
else
|
|
524
524
|
'--disable-content-trust'
|
|
525
525
|
end
|
|
526
|
-
opts << '--quiet'
|
|
526
|
+
opts << '--quiet' if silent?
|
|
527
527
|
return image(:push, opts, id: latest, registry: registry)
|
|
528
528
|
else
|
|
529
529
|
if op.empty?
|
|
@@ -804,14 +804,14 @@ module Squared
|
|
|
804
804
|
unless y
|
|
805
805
|
bb = index.to_s
|
|
806
806
|
cc = bb.size.succ
|
|
807
|
-
a = sub_style
|
|
808
|
-
b = "Execute #{sub_style(flag,
|
|
807
|
+
a = sub_style ee, theme[:inline]
|
|
808
|
+
b = "Execute #{sub_style(flag, theme[:active])} on #{a.subhint(ee == id ? nil : id)}"
|
|
809
809
|
e = time_format(time_since(data['CreatedAt']), pass: ['ms'])
|
|
810
|
-
f = sub_style
|
|
810
|
+
f = sub_style ARG[:BORDER][0], theme[:inline]
|
|
811
811
|
g = ' ' * cc.succ
|
|
812
|
-
h = "#{sub_style(bb.rjust(cc),
|
|
812
|
+
h = "#{sub_style(bb.rjust(cc), theme[:current])} #{f} "
|
|
813
813
|
puts unless index == 1
|
|
814
|
-
puts (h + sub_style(aa,
|
|
814
|
+
puts (h + sub_style(aa, theme[:subject])).subhint("created #{e} ago")
|
|
815
815
|
cols = %w[Tag Status Ports]
|
|
816
816
|
cols << case flag
|
|
817
817
|
when :connect, :disconnect
|
|
@@ -825,7 +825,7 @@ module Squared
|
|
|
825
825
|
puts "#{g + f} #{key}: #{Array(data[key]).join(', ')}" unless data[key].to_s.empty?
|
|
826
826
|
end
|
|
827
827
|
w = 9 + flag.to_s.size + 4 + ee.size
|
|
828
|
-
puts g + sub_style(ARG[:BORDER][6] + (ARG[:BORDER][1] * w),
|
|
828
|
+
puts g + sub_style(ARG[:BORDER][6] + (ARG[:BORDER][1] * w), theme[:inline])
|
|
829
829
|
index += 1
|
|
830
830
|
next unless confirm("#{h + b}?", no ? 'N' : 'Y')
|
|
831
831
|
|
|
@@ -855,9 +855,9 @@ module Squared
|
|
|
855
855
|
])
|
|
856
856
|
printsucc
|
|
857
857
|
a = t.last.capitalize
|
|
858
|
-
b = sub_style
|
|
859
|
-
c =
|
|
860
|
-
confirm "#{a} #{b}#{
|
|
858
|
+
b = sub_style target, theme[:subject]
|
|
859
|
+
c = sub_style as, theme[:inline] if as
|
|
860
|
+
confirm "#{a} #{b}#{" as #{c}" if c}?", 'N'
|
|
861
861
|
end
|
|
862
862
|
|
|
863
863
|
def choice_command(flag, *action)
|
|
@@ -923,7 +923,7 @@ module Squared
|
|
|
923
923
|
end
|
|
924
924
|
cmd.merge(Array(out).map! { |val| parse.call(val) })
|
|
925
925
|
cmd << args
|
|
926
|
-
success?(run(cmd), ctx.start_with?(/
|
|
926
|
+
success?(run(cmd), ctx.start_with?(/network|tag|save/))
|
|
927
927
|
end
|
|
928
928
|
|
|
929
929
|
def filetype(val = dockerfile)
|