squared 0.5.0 → 0.5.2

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.
@@ -9,7 +9,6 @@ module Squared
9
9
  module Workspace
10
10
  module Project
11
11
  class Base
12
- include Comparable
13
12
  include Common::Format
14
13
  include System
15
14
  include Shell
@@ -17,6 +16,7 @@ module Squared
17
16
  include Utils
18
17
  include Support
19
18
  include Rake::DSL
19
+ include ::Comparable
20
20
 
21
21
  VAR_SET = %i[parent global script index envname desc dependfile dependindex theme archive env dev prod graph
22
22
  pass exclude].freeze
@@ -99,7 +99,7 @@ module Squared
99
99
  last: last,
100
100
  error: error
101
101
  }
102
- @envname = @name.gsub(/[^\w]+/, '_').upcase.freeze
102
+ @envname = env_key(@name).freeze
103
103
  @desc = (@name.include?(':') ? @name.split(':').join(ARG[:SPACE]) : @name).freeze
104
104
  @parent = nil
105
105
  @global = false
@@ -205,7 +205,7 @@ module Squared
205
205
  file &&= @workspace.home.join(env('LOG_DIR', ''), file).realdirpath
206
206
  rescue StandardError => e
207
207
  file = nil
208
- warn log_message(Logger::WARN, e, pass: true) if warning?
208
+ warn log_message(Logger::WARN, e) if warning?
209
209
  end
210
210
  log[:progname] ||= @name
211
211
  if (val = env('LOG_LEVEL', ignore: false))
@@ -243,21 +243,26 @@ module Squared
243
243
  end
244
244
  end
245
245
 
246
+ def ==(other)
247
+ equal?(other)
248
+ end
249
+
246
250
  def <=>(other)
247
- return 0 unless workspace == other.workspace
251
+ return unless workspace == other.workspace
252
+ return 0 if equal?(other)
248
253
 
249
254
  a, b = graph_deps
250
255
  return 1 if a.include?(other)
251
256
 
252
257
  c, d = graph_deps other
253
- e = b.reject { |val| d.include?(val) }
254
- f = d.reject { |val| b.include?(val) }
258
+ e = b - d
259
+ f = d - b
255
260
  if parent == other.parent
256
261
  g = []
257
262
  h = []
258
263
  else
259
- g = a.reject { |val| c.include?(val) }
260
- h = c.reject { |val| a.include?(val) }
264
+ g = a - c
265
+ h = c - a
261
266
  end
262
267
  g << self
263
268
  h << other
@@ -272,13 +277,11 @@ module Squared
272
277
  elsif f.any? { |val| e.include?(val) }
273
278
  1
274
279
  elsif @index >= 0 && (i = other.instance_variable_get(:@index)) >= 0
275
- @index <= i ? -1 : 1
276
- else
277
- 0
280
+ @index <=> i
278
281
  end
279
282
  rescue StandardError => e
280
283
  log&.debug e
281
- 0
284
+ nil
282
285
  end
283
286
 
284
287
  def ref
@@ -411,7 +414,7 @@ module Squared
411
414
 
412
415
  out = obj.link(self, *args, **kwargs, &blk) if obj.respond_to?(:link)
413
416
  if !out
414
- warn log_message(Logger::WARN, 'link not compatible', subject: obj.to_s, hint: name, pass: true)
417
+ warn log_message(Logger::WARN, 'link not compatible', subject: obj.to_s, hint: name)
415
418
  elsif out.respond_to?(:build)
416
419
  out.build
417
420
  end
@@ -466,9 +469,9 @@ module Squared
466
469
  case opts
467
470
  when Hash
468
471
  opts = append_hash(opts, build: true)
469
- cmd = as_a(cmd).append(flags).concat(opts).compact.join(' ')
472
+ cmd = Array(cmd).append(flags).concat(opts).compact.join(' ')
470
473
  when Enumerable
471
- cmd = as_a(cmd).concat(opts.to_a)
474
+ cmd = Array(cmd).concat(opts.to_a)
472
475
  cmd.map! { |val| "#{val} #{flags}" } if flags
473
476
  cmd = cmd.join(' && ')
474
477
  else
@@ -498,15 +501,13 @@ module Squared
498
501
  begin
499
502
  proj.__send__(meth, sync: sync)
500
503
  rescue StandardError => e
501
- ret = on(:error, :prereqs, e)
504
+ ret = on :error, :prereqs, e
502
505
  raise unless ret == true
503
506
  else
504
507
  next
505
508
  end
506
509
  end
507
- if warning?
508
- warn log_message(Logger::WARN, name, 'method not found', subject: 'prereqs', hint: meth, pass: true)
509
- end
510
+ warn log_message(Logger::WARN, name, 'method not found', subject: 'prereqs', hint: meth)
510
511
  end
511
512
  elsif proj.build?
512
513
  proj.build(sync: sync)
@@ -557,7 +558,7 @@ module Squared
557
558
  @clean.each { |cmd, opts| build(cmd.to_s, opts, sync: sync) }
558
559
  rescue StandardError => e
559
560
  log&.error e
560
- ret = on(:error, from, e)
561
+ ret = on :error, from, e
561
562
  raise if exception && ret != true
562
563
  end
563
564
  else
@@ -607,7 +608,7 @@ module Squared
607
608
  end
608
609
  ret = graph_branch(self, data, tasks, out, sync: sync, pass: pass)
609
610
  rescue StandardError => e
610
- ret = on(:error, :graph, e)
611
+ ret = on :error, :graph, e
611
612
  raise unless ret == true
612
613
  else
613
614
  if out
@@ -651,7 +652,7 @@ module Squared
651
652
  headers = headers.is_a?(Hash) ? headers.merge(val) : val
652
653
  end
653
654
  data = nil
654
- (uri = as_a(uri)).each_with_index do |url, index|
655
+ (uri = Array(uri)).each_with_index do |url, index|
655
656
  URI.open(url, headers) do |f|
656
657
  data = f.read
657
658
  if algo && algo.hexdigest(data) != digest
@@ -689,7 +690,7 @@ module Squared
689
690
  file.write(data)
690
691
  file.close
691
692
  if create
692
- warn log_message(Logger::WARN, 'force remove', subject: name, hint: target, pass: true)
693
+ warn log_message(Logger::WARN, 'force remove', subject: name, hint: target)
693
694
  target.rmtree
694
695
  target.mkpath
695
696
  end
@@ -809,6 +810,8 @@ module Squared
809
810
  exclude_set val
810
811
  when :parent
811
812
  parent_set val
813
+ when :archive
814
+ archive_set val
812
815
  when :run
813
816
  run_set(*args, **kwargs)
814
817
  when :script
@@ -963,16 +966,28 @@ module Squared
963
966
  puts_oe(*args, pipe: pipe)
964
967
  end
965
968
 
966
- def run(cmd = @session, var = nil, exception: @exception, sync: true, from: nil, banner: true, chdir: path, **)
969
+ def run(cmd = @session, var = nil, exception: @exception, sync: true, from: nil, banner: true, chdir: path,
970
+ interactive: nil, **)
967
971
  unless cmd
968
- if warning?
969
- from &&= from.to_s
970
- warn log_message(Logger::WARN, from || 'unknown', subject: project, hint: 'no command given', pass: true)
971
- end
972
- return
972
+ from = from&.to_s || 'unknown'
973
+ return warn log_message(Logger::WARN, 'no command given', subject: project, hint: from, pass: true)
973
974
  end
975
+ i = interactive && !(@session && option('y'))
974
976
  cmd = cmd.target if cmd.is_a?(OptionPartition)
975
977
  cmd = session_done cmd
978
+ if i
979
+ title, y = case interactive
980
+ when Array
981
+ interactive
982
+ when String
983
+ [interactive, 'N']
984
+ else
985
+ ['Run', 'Y']
986
+ end
987
+ unless confirm("#{title}? [#{sub_style(cmd, styles: theme[:inline])}]", y)
988
+ raise_error('user cancelled', hint: from)
989
+ end
990
+ end
976
991
  log&.info cmd
977
992
  on :first, from
978
993
  begin
@@ -996,7 +1011,7 @@ module Squared
996
1011
  end
997
1012
  rescue StandardError => e
998
1013
  log&.error e
999
- ret = on(:error, from, e)
1014
+ ret = on :error, from, e
1000
1015
  raise unless ret == true
1001
1016
 
1002
1017
  false
@@ -1011,7 +1026,7 @@ module Squared
1011
1026
  begin
1012
1027
  cmd.flatten.each { |val| run(val, env, sync: sync, banner: banner, **kwargs) }
1013
1028
  rescue StandardError => e
1014
- ret = on(:error, from, e)
1029
+ ret = on :error, from, e
1015
1030
  raise unless ret == true
1016
1031
  end
1017
1032
  on :last, from
@@ -1033,7 +1048,7 @@ module Squared
1033
1048
  elsif obj.is_a?(Array) && obj.any? { |val| !val.is_a?(String) }
1034
1049
  build(*obj, **kwargs)
1035
1050
  elsif obj
1036
- run_s(obj.is_a?(Enumerable) ? obj.to_a : obj, **kwargs)
1051
+ run_s(*Array(obj), **kwargs)
1037
1052
  end
1038
1053
  end
1039
1054
  end
@@ -1080,7 +1095,7 @@ module Squared
1080
1095
 
1081
1096
  t = dedupe.call(proj.name)
1082
1097
  j = if out
1083
- if i == items.size - 1 || check.call(post = items[i + 1..-1]).empty?
1098
+ if i == items.size - 1 || check.call(post = items[(i + 1)..-1]).empty?
1084
1099
  true
1085
1100
  elsif !t.empty? && depth > 0
1086
1101
  post.reject { |pr| t.include?(pr) }.empty?
@@ -1092,9 +1107,9 @@ module Squared
1092
1107
  end
1093
1108
  if !out
1094
1109
  if !tasks && (script = workspace.script_get(:graph, group: proj.group, ref: proj.allref))
1095
- group = script[:graph]
1110
+ tasks = script[:graph]
1096
1111
  end
1097
- (tasks || group || (dev? ? ['build', 'copy'] : ['depend', 'build'])).each do |meth|
1112
+ (tasks || (dev? ? ['build', 'copy'] : ['depend', 'build'])).each do |meth|
1098
1113
  next if pass.include?(meth)
1099
1114
 
1100
1115
  if workspace.task_defined?(cmd = task_join(proj.name, meth))
@@ -1105,7 +1120,7 @@ module Squared
1105
1120
  end
1106
1121
  run(cmd, sync: false, banner: false)
1107
1122
  ENV.delete(key) if key
1108
- elsif proj.has?(meth, tasks || group ? nil : workspace.baseref)
1123
+ elsif proj.has?(meth, tasks ? nil : workspace.baseref)
1109
1124
  proj.__send__(meth.to_sym, sync: sync)
1110
1125
  end
1111
1126
  end
@@ -1130,7 +1145,7 @@ module Squared
1130
1145
  done
1131
1146
  end
1132
1147
 
1133
- def graph_collect(target, start = [], data: {}, pass: [])
1148
+ def graph_collect(target, start = [], data: {}, pass: [], root: [])
1134
1149
  deps = []
1135
1150
  (start.empty? ? target.instance_variable_get(:@graph) : start)&.each do |val|
1136
1151
  next if pass.include?(val)
@@ -1142,12 +1157,13 @@ module Squared
1142
1157
  else
1143
1158
  items = workspace.find(group: val, ref: val.to_sym)
1144
1159
  end
1145
-
1146
1160
  items.each do |proj|
1147
- next if pass.include?(proj.name)
1161
+ next if pass.include?(name = proj.name)
1148
1162
 
1149
- graph_collect(proj, data: data, pass: pass) if proj.graph? && !data.key?(proj.name)
1150
- next if (objs = data.fetch(proj.name, [])).include?(target)
1163
+ if proj.graph? && !data.key?(name) && !root.include?(name)
1164
+ graph_collect(proj, data: data, pass: pass, root: root + [name, target.name])
1165
+ end
1166
+ next if (objs = data.fetch(name, [])).include?(target)
1151
1167
 
1152
1168
  deps << proj
1153
1169
  deps.concat(objs)
@@ -1187,7 +1203,7 @@ module Squared
1187
1203
  end
1188
1204
  return ret == equals.to_s unless equals.nil?
1189
1205
 
1190
- ret.empty? || (ignore && as_a(ignore).any? { |val| ret == val.to_s }) ? default : ret
1206
+ ret.empty? || (ignore && Array(ignore).any? { |val| ret == val.to_s }) ? default : ret
1191
1207
  end
1192
1208
 
1193
1209
  def session(*cmd, prefix: cmd.first, main: true, path: true, options: true)
@@ -1235,10 +1251,9 @@ module Squared
1235
1251
  def option(*args, target: @session, prefix: target&.first, **kwargs)
1236
1252
  if prefix
1237
1253
  args.each do |val|
1238
- next unless (ret = env("#{stripext(prefix)}_#{val.gsub(/\W/, '_')}".upcase, **kwargs))
1239
- return ret unless block_given?
1254
+ next unless (ret = env(env_key(stripext(prefix), val), **kwargs))
1240
1255
 
1241
- return yield ret
1256
+ return block_given? ? yield(ret) : ret
1242
1257
  end
1243
1258
  end
1244
1259
  nil
@@ -1296,6 +1311,18 @@ module Squared
1296
1311
  ret.join("\n")
1297
1312
  end
1298
1313
 
1314
+ def print_status(*args, from: nil)
1315
+ return if stdin?
1316
+
1317
+ case from
1318
+ when :outdated
1319
+ out = print_footer("major #{args[0]} / minor #{args[1]} / patch #{args[2]}", right: true).split("\n")
1320
+ out[1] = sub_style(out[1], pat: /^( +major )(\d+)(.+)$/, styles: theme[:major], index: 2)
1321
+ out[1] = sub_style(out[1], pat: /^(.+)(minor )(\d+)(.+)$/, styles: theme[:active], index: 3)
1322
+ puts out
1323
+ end
1324
+ end
1325
+
1299
1326
  def format_desc(action, flag, opts = nil, **kwargs)
1300
1327
  return unless TASK_METADATA
1301
1328
 
@@ -1310,7 +1337,7 @@ module Squared
1310
1337
 
1311
1338
  client = true
1312
1339
  else
1313
- data = Workspace::Support::BannerData.new(true, [:path], theme[:banner], theme[:border])
1340
+ data = Struct::BannerData.new(true, [:path], theme[:banner], theme[:border])
1314
1341
  end
1315
1342
  if verbose
1316
1343
  out = []
@@ -1356,7 +1383,7 @@ module Squared
1356
1383
  items.each_with_index do |val, i|
1357
1384
  next unless reg.empty? || reg.any? { |pat| val[0].match?(pat) }
1358
1385
 
1359
- out << "#{i.succ.to_s.rjust(pad)}. #{each ? each.call(val) : val[0]}"
1386
+ out << ('%*d. %s' % [pad, i.succ, each ? each.call(val) : val[0]])
1360
1387
  end
1361
1388
  end
1362
1389
  sub = [headerstyle]
@@ -1368,7 +1395,7 @@ module Squared
1368
1395
  out << ''
1369
1396
  end
1370
1397
  if from
1371
- out << from
1398
+ out << (from = from.to_s)
1372
1399
  pat = /\A(#{Regexp.escape(from)})(.*)\z/
1373
1400
  end
1374
1401
  else
@@ -1539,7 +1566,7 @@ module Squared
1539
1566
  raise_error("invalid JSON #{kind.name}", val, hint: hint) if kind && !ret.is_a?(kind)
1540
1567
  rescue StandardError => e
1541
1568
  log&.warn e
1542
- warn log_message(Logger::WARN, e, subject: name, pass: true) if warning?
1569
+ warn log_message(Logger::WARN, e, subject: name) if warning?
1543
1570
  else
1544
1571
  ret
1545
1572
  end
@@ -1568,9 +1595,9 @@ module Squared
1568
1595
  'PATCH'
1569
1596
  end, styles: (rev == 1 && theme[:major]) || theme[:header])
1570
1597
  b = sub_style(pkg.ljust(col1), styles: theme[:inline])
1571
- c, d = rev == 1 || lock ? ['y/N', 'N'] : ['Y/n', 'Y']
1572
- e = lock ? sub_style((cur || 'locked').rjust(7), styles: color(:red)) : cur&.rjust(7)
1573
- confirm "#{a}: #{b}#{e} #{sub_style(ver.rjust(col1 > 0 ? 10 : 0), styles: theme[:inline])} [#{c}] ", d
1598
+ c = lock ? sub_style((cur || 'locked').rjust(7), styles: color(:red)) : cur&.rjust(7)
1599
+ d = rev == 1 || lock ? 'N' : 'Y'
1600
+ confirm "#{a}: #{b}#{c} #{sub_style(ver.rjust(col1 > 0 ? 10 : 0), styles: theme[:inline])} ", d
1574
1601
  end
1575
1602
 
1576
1603
  def choice_index(msg, list, values: nil, accept: nil, series: false, trim: nil, column: nil,
@@ -1587,25 +1614,27 @@ module Squared
1587
1614
  end
1588
1615
  ret = multiple ? ret.map! { |val| val.sub(trim, '') } : ret.sub(trim, '') if trim
1589
1616
  if column
1590
- a, b = as_a column
1591
- ret = as_a(ret).map! { |val| val[a, b || 1] }
1617
+ a, b = Array(column)
1618
+ ret = Array(ret).map! { |val| val[a, b || 1] }
1592
1619
  ret = ret.first unless multiple
1593
1620
  end
1594
1621
  if accept
1595
- a = as_a(ret).map { |val| sub_style(val, styles: theme[:inline]) }.join(', ')
1596
- accept = as_a(accept).map { |val| as_a(val) }
1622
+ hint = Array(ret).map { |val| sub_style(val, styles: theme[:inline]) }.join(', ')
1623
+ accept = Array(accept).map { |val| Array(val) }
1597
1624
  if accept.any? { |val| val[1] == true }
1598
1625
  ret = [ret]
1599
1626
  multiple = -1
1600
1627
  end
1601
1628
  loop do
1602
- c = confirm("#{accept.first[0]}#{a ? " [#{a}]" : ''} [y/N] ", 'N', timeout: 60)
1603
- if accept.shift[1] == true
1629
+ item = accept.first
1630
+ c = confirm("#{item[0]}#{a ? " [#{hint}]" : ''}", item[2] ? 'Y' : 'N', timeout: 60)
1631
+ if item[1] == true
1604
1632
  ret << c
1605
1633
  elsif !c
1606
1634
  break
1607
1635
  end
1608
- a = nil
1636
+ hint = nil
1637
+ accept.shift
1609
1638
  break if accept.empty?
1610
1639
  end
1611
1640
  exit 1 unless accept.empty?
@@ -1636,7 +1665,7 @@ module Squared
1636
1665
  if (ret = instance_eval(&blk)).nil?
1637
1666
  val
1638
1667
  else
1639
- ret.is_a?(Array) ? ret : [ret]
1668
+ Array(ret)
1640
1669
  end
1641
1670
  end
1642
1671
 
@@ -1689,19 +1718,24 @@ module Squared
1689
1718
  end
1690
1719
 
1691
1720
  def indexitem(val)
1692
- [$1.to_i, $2 && $2[1..-1]] if val =~ /\A\^(\d+)(:.+)?\z/
1721
+ [$1.to_i, $2 && $2[1..-1]] if val =~ /\A[=^#{indexchar}](\d+)(:.+)?\z/
1693
1722
  end
1694
1723
 
1695
1724
  def indexerror(val, list = nil)
1696
1725
  raise_error("requested index #{val}", hint: list && "of #{list.size}")
1697
1726
  end
1698
1727
 
1728
+ def indexchar
1729
+ workspace.windows? ? '=' : '^'
1730
+ end
1731
+
1699
1732
  def printsucc
1700
1733
  @@print_order += 1
1701
1734
  end
1702
1735
 
1703
1736
  def color(val)
1704
- theme[val].yield_self { |styles| styles && !styles.empty? ? styles : [val] }
1737
+ ret = theme[val]
1738
+ ret && !ret.empty? ? ret : [val]
1705
1739
  end
1706
1740
 
1707
1741
  def colormap(val)
@@ -1744,8 +1778,9 @@ module Squared
1744
1778
  end
1745
1779
 
1746
1780
  def pwd_set(pass: false, from: nil)
1781
+ pass = semscan(pass).join <= RUBY_VERSION if pass.is_a?(String)
1747
1782
  pwd = Dir.pwd
1748
- if path.to_s == pwd || pass == true || (pass.is_a?(String) && semscan(pass).join <= RUBY_VERSION)
1783
+ if (path.to_s == pwd || pass == true) && !workspace.jruby_win?
1749
1784
  ret = yield
1750
1785
  else
1751
1786
  Dir.chdir(path)
@@ -1753,9 +1788,8 @@ module Squared
1753
1788
  Dir.chdir(pwd)
1754
1789
  end
1755
1790
  rescue StandardError => e
1756
- puts e
1757
1791
  log&.error e
1758
- ret = on(:error, from, e)
1792
+ ret = on :error, from, e
1759
1793
  raise if exception && ret != true
1760
1794
  else
1761
1795
  ret
@@ -1852,7 +1886,7 @@ module Squared
1852
1886
 
1853
1887
  def graph_set(val)
1854
1888
  @graph = if val
1855
- as_a(val).map { |s| workspace.prefix ? workspace.task_name(s).to_sym : s.to_sym }.freeze
1889
+ Array(val).map { |s| workspace.prefix ? workspace.task_name(s).to_sym : s.to_sym }.freeze
1856
1890
  end
1857
1891
  end
1858
1892
 
@@ -1982,6 +2016,10 @@ module Squared
1982
2016
  ARG[:BANNER] && !env('BANNER', equals: '0')
1983
2017
  end
1984
2018
 
2019
+ def pwd?
2020
+ path == Pathname.pwd
2021
+ end
2022
+
1985
2023
  def stdin?
1986
2024
  pipe == 0
1987
2025
  end
@@ -21,7 +21,8 @@ module Squared
21
21
  compose: {
22
22
  common: %w[all-resources compatibility dry-run ansi|b env-file=p f|file=p parallel=b profile=b progress=b
23
23
  project-directory=p p|project-name=e].freeze,
24
- build: %w[no-cache pull push with-dependencies q|quiet build-arg=qq builder=b m|memory=b ssh=qq].freeze,
24
+ build: %w[check no-cache pull push with-dependencies q|quiet build-arg=qq builder=b m|memory=b
25
+ ssh=qq].freeze,
25
26
  exec: %w[dry-run privileged d|detach e|env=qq index=i T|no-TTY=b? user=e w|workdir=q].freeze,
26
27
  run: %w[build dry-run no-deps quiet-pull remove-orphans rm P|service-ports use-aliases cap-add=b cap-drop=b
27
28
  d|detach entrypoint=q e|env=qq i|interactive=b? l|label=q name=b T|no-TTY=b? p|publish=e pull=b
@@ -160,7 +161,7 @@ module Squared
160
161
  compose! flag, args.to_a
161
162
  end
162
163
  when :exec, :run
163
- format_desc action, flag, "service,command#{flag == :exec ? '' : '?'},args*,opts*"
164
+ format_desc action, flag, "service,command#{flag == :exec ? '' : '?'}|:,args*,opts*"
164
165
  task flag, [:service] do |_, args|
165
166
  service = param_guard(action, flag, args: args, key: :service)
166
167
  compose!(flag, args.extras, service: service)
@@ -265,7 +266,6 @@ module Squared
265
266
  when Enumerable
266
267
  ret.merge(opts.to_a)
267
268
  end
268
-
269
269
  [args, flags].each_with_index do |target, index|
270
270
  if (data = append_any(target, target: []))
271
271
  ret.merge(data.map { |arg| index == 0 ? fill_option(arg) : quote_option('build-arg', arg) })
@@ -278,12 +278,12 @@ module Squared
278
278
  ret << quote_option('secret', @secrets, double: true)
279
279
  when Hash
280
280
  append = lambda do |type|
281
- as_a(@secrets[type]).each { |arg| ret << quote_option('secret', "type=#{type},#{arg}", double: true) }
281
+ Array(@secrets[type]).each { |arg| ret << quote_option('secret', "type=#{type},#{arg}", double: true) }
282
282
  end
283
283
  append.call(:file)
284
284
  append.call(:env)
285
285
  else
286
- as_a(@secrets).each { |arg| ret << quote_option('secret', arg) }
286
+ Array(@secrets).each { |arg| ret << quote_option('secret', arg) }
287
287
  end
288
288
  if (val = option('tag', ignore: false))
289
289
  append_tag val
@@ -311,7 +311,7 @@ module Squared
311
311
  when :bake
312
312
  unless op.empty?
313
313
  args = op.dup
314
- op.extras.clear
314
+ op.reset
315
315
  if Dir.exist?(args.last)
316
316
  if projectpath?(val = args.pop)
317
317
  context = val
@@ -358,7 +358,7 @@ module Squared
358
358
  both = run[:bind] + run[:tmpfs]
359
359
  diff = run[:bind].reject { |val| run[:tmpfs].include?(val) }
360
360
  delim = Regexp.new(",\\s*(?=#{both.join('|')})")
361
- as_a(@mounts).each do |val|
361
+ Array(@mounts).each do |val|
362
362
  args = []
363
363
  tmpfs = true
364
364
  val.split(delim).each do |opt|
@@ -564,7 +564,9 @@ module Squared
564
564
  end
565
565
 
566
566
  def append_command(flag, val, list, target: @session, from: nil)
567
- if (args = env('DOCKER_ARGS'))
567
+ if list.delete(':')
568
+ list << readline('Enter command [args]', force: true)
569
+ elsif (args = env('DOCKER_ARGS'))
568
570
  list << args
569
571
  end
570
572
  case flag
@@ -587,7 +589,7 @@ module Squared
587
589
  def append_file(type, target: @session)
588
590
  return unless type == 2 || type == 4 || @file.is_a?(Array)
589
591
 
590
- files = as_a(@file).map { |val| quote_option('file', path + val) }
592
+ files = Array(@file).map { |val| quote_option('file', path + val) }
591
593
  if target.is_a?(Set)
592
594
  target.merge(files)
593
595
  else
@@ -646,7 +648,6 @@ module Squared
646
648
  cc = bb.size + 1
647
649
  a = sub_style(ee, styles: theme[:inline])
648
650
  b = "Execute #{sub_style(flag, styles: theme[:active])} on #{a}#{ee == id ? '' : " (#{id})"}"
649
- c, d = no ? ['y/N', 'N'] : ['Y/n', 'Y']
650
651
  e = time_format(time_since(data['CreatedAt']), pass: ['ms'])
651
652
  f = sub_style(ARG[:BORDER][0], styles: theme[:inline])
652
653
  g = ' ' * (cc + 1)
@@ -663,13 +664,13 @@ module Squared
663
664
  cols.each do |key|
664
665
  next if (key == 'Tag' && !dd) || (key == 'Size' && data[key] == '0B')
665
666
 
666
- puts "#{g + f} #{key}: #{as_a(data[key]).join(', ')}" unless data[key].to_s.empty?
667
+ puts "#{g + f} #{key}: #{Array(data[key]).join(', ')}" unless data[key].to_s.empty?
667
668
  end
668
669
  w = 9 + flag.to_s.size + 4 + ee.size
669
670
  puts g + sub_style(ARG[:BORDER][6] + (ARG[:BORDER][1] * w), styles: theme[:inline])
670
671
  found = true
671
672
  index += 1
672
- next unless confirm("#{h + b}? [#{c}] ", d, timeout: 60)
673
+ next unless confirm("#{h + b}?", no ? 'N' : 'Y', timeout: 60)
673
674
 
674
675
  puts if printfirst?
675
676
  end
@@ -679,7 +680,7 @@ module Squared
679
680
  end
680
681
  rescue StandardError => e
681
682
  log.error e
682
- ret = on(:error, from, e)
683
+ ret = on :error, from, e
683
684
  raise if exception && ret != true
684
685
 
685
686
  warn log_message(Logger::WARN, e, pass: true) if warning?
@@ -698,7 +699,7 @@ module Squared
698
699
  a = t.last.capitalize
699
700
  b = sub_style(target, styles: theme[:subject])
700
701
  c = as && sub_style(as, styles: theme[:inline])
701
- confirm("#{a} #{b}#{c ? " as #{c}" : ''}? [y/N] ", 'N', timeout: 60)
702
+ confirm("#{a} #{b}#{c ? " as #{c}" : ''}?", 'N', timeout: 60)
702
703
  end
703
704
 
704
705
  def choice_command(flag)