squared 0.4.5 → 0.4.7

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.
@@ -2,7 +2,9 @@
2
2
 
3
3
  require 'json'
4
4
  require 'date'
5
+ require 'time'
5
6
  require 'logger'
7
+ require 'digest'
6
8
 
7
9
  module Squared
8
10
  module Workspace
@@ -13,6 +15,7 @@ module Squared
13
15
  include Shell
14
16
  include Prompt
15
17
  include Utils
18
+ include Support
16
19
  include Rake::DSL
17
20
 
18
21
  VAR_SET = %i[parent global envname dependfile dependindex theme run script env pass].freeze
@@ -70,7 +73,7 @@ module Squared
70
73
  :group, :parent, :dependfile
71
74
 
72
75
  def initialize(workspace, path, name, *, group: nil, graph: nil, pass: nil, exclude: nil, release: nil,
73
- archive: nil, first: {}, last: {}, error: {}, common: ARG[:COMMON], **kwargs)
76
+ archive: nil, verbose: nil, first: {}, last: {}, error: {}, common: ARG[:COMMON], **kwargs)
74
77
  @path = path
75
78
  @workspace = workspace
76
79
  @name = name.to_s.freeze
@@ -97,7 +100,7 @@ module Squared
97
100
  when nil
98
101
  workspace.verbose
99
102
  when String
100
- env_pipe(verbose, workspace.verbose, strict: true, index: true)
103
+ env_bool(verbose, workspace.verbose, strict: true, index: true)
101
104
  else
102
105
  verbose
103
106
  end
@@ -192,19 +195,24 @@ module Squared
192
195
  return if @log
193
196
 
194
197
  log = log.is_a?(Hash) ? log.dup : { file: log }
195
- unless (file = env('LOG_FILE'))
196
- file = case env('LOG_AUTO')
197
- when 'y', 'year'
198
- "#{@name}-#{Date.today.year}.log"
199
- when 'm', 'month'
200
- "#{@name}-#{Date.today.strftime('%Y-%m')}.log"
201
- when 'd', 'day', '1'
202
- "#{@name}-#{Date.today}.log"
203
- end
204
- end
205
- if file ||= log[:file]
206
- file = Date.today.strftime(file)
207
- file = (dir = env('LOG_DIR')) ? @workspace.home.join(dir, file) : @workspace.home.join(file)
198
+ if (file = env('LOG_FILE'))
199
+ file = Time.now.strftime(file)
200
+ elsif (val = env('LOG_AUTO'))
201
+ file = "#{@name}-%s.log" % [case val
202
+ when 'y', 'year'
203
+ Date.today.year
204
+ when 'm', 'month'
205
+ Date.today.strftime('%Y-%m')
206
+ when 'd', 'day', '1'
207
+ Date.today
208
+ else
209
+ val.include?('%') ? Time.now.strftime(val) : Time.now.strftime('%FT%T%:z')
210
+ end]
211
+ elsif (val = log[:file])
212
+ file = val.is_a?(String) ? Time.now.strftime(val) : "#{@name}-#{Date.today}.log"
213
+ end
214
+ if file
215
+ file = (val = env('LOG_DIR')) ? @workspace.home.join(val, file) : @workspace.home.join(file)
208
216
  begin
209
217
  file = file.realdirpath
210
218
  rescue StandardError => e
@@ -395,7 +403,7 @@ module Squared
395
403
 
396
404
  run_b(@run, sync: sync, from: from) if series?(@run)
397
405
  args = @output
398
- banner = verbose == 1 if task_invoked?('build', 'build:sync', 'default')
406
+ banner = verbosetype > 1 if task_invoked?('build', 'build:sync', 'default')
399
407
  end
400
408
  if args.all? { |val| val.is_a?(Array) }
401
409
  cmd = []
@@ -450,7 +458,7 @@ module Squared
450
458
  end
451
459
 
452
460
  def archive(*, sync: invoked_sync?('archive'), **)
453
- return unless @archive.is_a?(Array)
461
+ return unless @archive.is_a?(Hash)
454
462
 
455
463
  unpack(path, **@archive, sync: sync, from: :archive)
456
464
  end
@@ -488,12 +496,11 @@ module Squared
488
496
  end
489
497
  else
490
498
  if @clean.is_a?(Enumerable) && !series?(@clean)
491
- as_a(@clean).each do |val|
492
- val = val.to_s
493
- path = basepath(val)
499
+ @clean.each do |val|
500
+ path = basepath(val = val.to_s)
494
501
  if path.directory? && val.match?(%r{[\\/]$})
495
502
  log&.warn "rm -rf #{path}"
496
- path.rmtree(verbose: verbose)
503
+ rm_rf(path, verbose: verbose)
497
504
  else
498
505
  log&.warn "rm #{path}"
499
506
  (val.include?('*') ? Dir[path] : [path]).each do |file|
@@ -519,15 +526,15 @@ module Squared
519
526
  tasks ||= []
520
527
  split_escape(val).each do |task|
521
528
  if ref?(task.to_sym) && (script = workspace.script_get(:graph, ref: task.to_sym))
522
- tasks += script[:graph]
529
+ tasks.concat(script[:graph])
523
530
  else
524
531
  tasks << task
525
532
  end
526
533
  end
527
534
  end
528
- pass += split_escape(val) if (val = env('GRAPH', suffix: 'PASS'))
535
+ pass.concat(split_escape(val)) if (val = env('GRAPH', suffix: 'PASS'))
529
536
  start, neg = start.partition { |name| !name.start_with?('-') }
530
- data = graph_collect(self, start, pass: neg.map { |name| name[1..-1] })
537
+ data = graph_collect(self, start, pass: neg.map! { |name| name[1..-1] })
531
538
  unless out
532
539
  data[name] << self
533
540
  on :first, :graph
@@ -582,11 +589,10 @@ module Squared
582
589
  if (val = env('HEADERS')) && (val = parse_json(val, hint: "HEADERS_#{@envname}"))
583
590
  headers = val
584
591
  end
585
- require 'open-uri'
586
592
  data = nil
587
593
  (uri = as_a(uri)).each_with_index do |url, index|
588
594
  last = index == uri.size - 1
589
- URI.open(url, headers) do |f|
595
+ fetch_uri(url, headers) do |f|
590
596
  data = f.read
591
597
  if algo && algo.hexdigest(data) != digest
592
598
  data = nil
@@ -610,7 +616,7 @@ module Squared
610
616
  raise_error('no content', hint: url)
611
617
  end
612
618
  end
613
- ext ||= URI.parse(uri).path[/^.+?\.((?:tar\.)?\w+)$/i, 1]
619
+ ext ||= URI.parse(uri).path[/\.(\w+)(\?|$)/i, 1]
614
620
  if (n = env("#{ext == 'zip' || ext == '7z' ? ext.upcase : 'TAR'}_DEPTH", ignore: false))
615
621
  depth = n.to_i
616
622
  end
@@ -624,7 +630,7 @@ module Squared
624
630
  target.rmtree
625
631
  target.mkpath
626
632
  end
627
- case ext
633
+ case ext.downcase
628
634
  when 'zip', 'aar'
629
635
  session 'unzip', shell_quote(file.path), quote_option('d', target)
630
636
  when 'tar', 'tgz', 'tar.gz', 'tar.xz', 'gz', 'xz'
@@ -648,8 +654,8 @@ module Squared
648
654
  break unless entry.directory?
649
655
 
650
656
  dest = target.join(File.basename(file.path))
651
- FileUtils.mv(entry, dest)
652
- dest.children.each { |child| FileUtils.mv(child, target) }
657
+ mv(entry, dest)
658
+ dest.children.each { |child| mv(child, target) }
653
659
  dest.rmdir
654
660
  target = entry
655
661
  depth -= 1
@@ -1043,7 +1049,7 @@ module Squared
1043
1049
  next if (objs = data.fetch(proj.name, [])).include?(target)
1044
1050
 
1045
1051
  deps << proj
1046
- deps += objs
1052
+ deps.concat(objs)
1047
1053
  end
1048
1054
  end
1049
1055
  data[target.name] = deps.uniq.reject { |proj| proj == target }
@@ -1066,8 +1072,8 @@ module Squared
1066
1072
  end
1067
1073
 
1068
1074
  def session(*cmd, prefix: cmd.first, main: true, path: true, options: true)
1069
- prefix = prefix.to_s.upcase
1070
- if path && (val = PATH[prefix] || PATH[prefix.to_sym])
1075
+ prefix = stripext(prefix.to_s).upcase
1076
+ if path && (val = ENV["PATH_#{prefix}"] || PATH[prefix] || PATH[prefix.to_sym])
1071
1077
  cmd[0] = shell_quote(val, force: false)
1072
1078
  end
1073
1079
  ret = JoinSet.new(cmd.flatten(1))
@@ -1077,9 +1083,9 @@ module Squared
1077
1083
  main ? @session = ret : ret
1078
1084
  end
1079
1085
 
1080
- def session_delete(*list, target: @session)
1086
+ def session_delete(*args, target: @session)
1081
1087
  ret = []
1082
- list.each do |val|
1088
+ args.each do |val|
1083
1089
  pat = /^#{Regexp.escape(shell_option(val))}(?: |=|$)/
1084
1090
  if (key = target.find { |opt| opt.match?(pat) })
1085
1091
  target.delete(key)
@@ -1101,120 +1107,25 @@ module Squared
1101
1107
  cmd.done
1102
1108
  end
1103
1109
 
1104
- def option(*args, prefix: @session&.first, **kwargs)
1110
+ def option(*args, target: @session, prefix: target&.first, **kwargs)
1105
1111
  if prefix
1106
1112
  args.each do |val|
1107
- ret = env("#{prefix}_#{val.gsub(/\W/, '_')}".upcase, **kwargs)
1113
+ ret = env("#{stripext(prefix)}_#{val.gsub(/\W/, '_')}".upcase, **kwargs)
1108
1114
  return ret if ret
1109
1115
  end
1110
1116
  end
1111
1117
  nil
1112
1118
  end
1113
1119
 
1114
- def option_sanitize(opts, list, target: @session, no: nil, single: nil, args: false, first: false, pass: ['='])
1115
- ret = []
1116
- reg = []
1117
- bare = []
1118
- e = []
1119
- b = []
1120
- m = []
1121
- p = []
1122
- q = []
1123
- qq = []
1124
- i = []
1125
- f = []
1126
- si = []
1127
- list = list.map do |val|
1128
- x, y = val.split('|')
1129
- if y
1130
- if (n = val.index('='))
1131
- x += val[n..-1]
1132
- end
1133
- [x, y]
1134
- else
1135
- x
1136
- end
1137
- end
1138
- list.flatten.each do |val|
1139
- if (n = val.index('='))
1140
- flag = val[0, n]
1141
- case val[n + 1]
1142
- when 'e'
1143
- e << flag
1144
- when 'b'
1145
- b << flag
1146
- when 'm'
1147
- m << flag
1148
- when 'q'
1149
- qq << flag if val[n + 2] == 'q'
1150
- q << flag
1151
- when 'p'
1152
- p << flag
1153
- when 'i'
1154
- i << flag
1155
- when 'f'
1156
- f << flag
1157
- when 'n'
1158
- si << flag
1159
- else
1160
- reg << Regexp.escape(flag)
1161
- end
1162
- bare << flag if val.end_with?('?')
1163
- else
1164
- bare << val
1165
- end
1166
- end
1167
- no = (no || []).map { |val| (n = val.index('=')) ? val[0, n] : val }
1168
- bare += no
1169
- found = false
1170
- opts.each do |opt|
1171
- next ret << opt if found
1172
-
1173
- if single&.match?(opt)
1174
- target << "-#{opt}"
1175
- elsif bare.include?(opt)
1176
- target << (opt.size == 1 ? "-#{opt}" : "--#{opt}")
1177
- elsif opt.start_with?('no-') && no.include?(name = opt[3..-1])
1178
- target << "--no-#{name}"
1179
- else
1180
- if opt =~ /\A([^=]+)=(.+)\z/
1181
- key = $1
1182
- val = $2
1183
- match = ->(flag, pat) { flag.include?(key) && pat.match?(val) }
1184
- if e.include?(key)
1185
- target << shell_option(key, val)
1186
- elsif q.include?(key)
1187
- target << quote_option(key, val, double: qq.include?(key))
1188
- elsif p.include?(key)
1189
- target << quote_option(key, basepath(val))
1190
- elsif m.include?(key)
1191
- target << basic_option(key, val, merge: true)
1192
- elsif b.include?(key) || match.(i, /^\d+$/) || match.(f, /^\d*(?:\.\d+)?$/) || match.(si, /^-?\d+$/)
1193
- target << basic_option(key, val)
1194
- else
1195
- ret << opt
1196
- end
1197
- opt = key
1198
- else
1199
- ret << opt
1200
- found = true if args
1201
- end
1202
- found = true if first && pass.none? { |s| opt.include?(s) }
1203
- end
1204
- end
1205
- [ret, reg.empty? ? /\A\s+\z/ : /^(#{reg.join('|')})=(.+)$/]
1120
+ def option_sanitize(opts, list, target: @session, **kwargs)
1121
+ op = OptionPartition.new(opts, list, target, project: self, **kwargs)
1122
+ [op.extras, op.values]
1206
1123
  end
1207
1124
 
1208
- def option_clear(opts, target: @session, pass: true, append: false, **kwargs)
1209
- return if opts.empty?
1210
-
1211
- kwargs[:subject] ||= target&.first
1212
- kwargs[:hint] ||= 'unrecognized'
1213
- warn log_message(Logger::WARN, opts.join(', '), pass: true, **kwargs)
1214
- append_value(opts, delim: true) if append
1215
- return if pass || confirm("Run? [#{sub_style(target, styles: theme[:inline])}] [y/N] ", 'N', timeout: 30)
1125
+ def option_clear(opts, target: @session, **kwargs)
1126
+ return unless target
1216
1127
 
1217
- raise_error 'user cancelled'
1128
+ OptionPartition.clear(target, opts, styles: theme[:inline], **kwargs)
1218
1129
  end
1219
1130
 
1220
1131
  def print_item(*val)
@@ -1235,7 +1146,7 @@ module Squared
1235
1146
  n = Project.max_width(lines)
1236
1147
  ch = ' ' * pad
1237
1148
  index = -1
1238
- out = lines.map do |val|
1149
+ lines.map! do |val|
1239
1150
  index += 1
1240
1151
  val = ch + val.ljust(n - (pad * 2)) + ch
1241
1152
  if styles && (pad == 1 || index == 0)
@@ -1244,8 +1155,7 @@ module Squared
1244
1155
  val
1245
1156
  end
1246
1157
  end
1247
- out << sub_style(ARG[:BORDER][1] * n, styles: border)
1248
- out.join("\n")
1158
+ (lines << sub_style(ARG[:BORDER][1] * n, styles: border)).join("\n")
1249
1159
  end
1250
1160
 
1251
1161
  def print_footer(*lines, sub: nil, reverse: false, right: false, **kwargs)
@@ -1330,7 +1240,7 @@ module Squared
1330
1240
  out = ["No #{type} were found:", '']
1331
1241
  unless grep.empty?
1332
1242
  i = 0
1333
- out += grep.map { |s| "#{i += 1}. #{s}" }
1243
+ out.concat(grep.map { |s| "#{i += 1}. #{s}" })
1334
1244
  out << ''
1335
1245
  end
1336
1246
  if from
@@ -1357,7 +1267,6 @@ module Squared
1357
1267
  end
1358
1268
 
1359
1269
  def append_hash(data, target: @session, build: false)
1360
- target ||= []
1361
1270
  if build && (type = env('BUILD', suffix: 'TYPE') || ENV['BUILD_TYPE'])
1362
1271
  type = "__#{type}__"
1363
1272
  if (extra = data[type] || data[type.to_sym]).is_a?(Hash)
@@ -1410,22 +1319,17 @@ module Squared
1410
1319
  end
1411
1320
  end
1412
1321
 
1413
- def append_value(*list, target: @session, delim: false, escape: false, quote: true)
1414
- return if (list = list.flatten).empty?
1322
+ def append_value(*list, target: @session, **kwargs)
1323
+ return unless target
1415
1324
 
1416
- target << '--' if delim && !target.include?('--')
1417
- list.map do |val|
1418
- item = escape ? shell_escape(val, quote: quote) : shell_quote(val)
1419
- target << item
1420
- item
1421
- end
1325
+ OptionPartition.append(target, *list, **kwargs)
1422
1326
  end
1423
1327
 
1424
1328
  def append_first(*list, target: @session, flag: true, equals: false, escape: true, quote: true, force: true,
1425
1329
  **kwargs)
1426
- return if (list = list.flatten).empty?
1330
+ return if list.empty?
1427
1331
 
1428
- list.each do |opt|
1332
+ list.flatten.each do |opt|
1429
1333
  next unless (val = option(opt, **kwargs))
1430
1334
 
1431
1335
  return target << (if flag
@@ -1439,11 +1343,11 @@ module Squared
1439
1343
 
1440
1344
  def append_option(*list, target: @session, no: false, equals: false, escape: true, quote: true, force: true,
1441
1345
  **kwargs)
1442
- return if (list = list.flatten).empty?
1346
+ return if list.empty?
1443
1347
 
1444
1348
  ret = []
1445
- list.each do |flag|
1446
- next unless (val = option(flag, **kwargs))
1349
+ list.flatten.each do |flag|
1350
+ next unless (val = option(flag, target: target, **kwargs))
1447
1351
 
1448
1352
  if val == '0' && no
1449
1353
  flag = "no-#{flag}"
@@ -1455,50 +1359,52 @@ module Squared
1455
1359
  end
1456
1360
 
1457
1361
  def append_nocolor(target: @session)
1458
- target << '--no-color' if !ARG[:COLOR] || stdin? || option('no-color', ignore: false)
1362
+ target << '--no-color' if !ARG[:COLOR] || stdin? || option('color', target: target, equals: '0')
1459
1363
  end
1460
1364
 
1461
1365
  def merge_opts(base, data)
1462
- return data unless base
1463
- return base unless data
1464
-
1465
- ret = case data
1466
- when String
1467
- case base
1468
- when String
1469
- "#{base} #{data}"
1470
- when Hash
1471
- "#{append_hash(base).join(' ')} #{data}"
1472
- when Enumerable
1473
- "#{base.to_a.join(' ')} #{data}"
1474
- end
1475
- when Hash
1476
- case base
1477
- when String
1478
- "#{base} #{append_hash(data).join(' ')}"
1479
- when Hash
1480
- base.merge(data)
1481
- when Enumerable
1482
- base.to_a + append_hash(data)
1483
- end
1484
- when Enumerable
1485
- case base
1486
- when String
1487
- "#{base} #{data.to_a.join(' ')}"
1488
- when Hash
1489
- "#{append_hash(base).join(' ')} #{data.to_a.join(' ')}"
1490
- when Enumerable
1491
- base.to_a + data.to_a
1492
- end
1493
- else
1494
- base
1495
- end
1496
- ret || data
1366
+ case data
1367
+ when String
1368
+ case base
1369
+ when String
1370
+ "#{base} #{data}"
1371
+ when Hash
1372
+ "#{append_hash(base).join(' ')} #{data}"
1373
+ when Enumerable
1374
+ "#{base.to_a.join(' ')} #{data}"
1375
+ else
1376
+ data
1377
+ end
1378
+ when Hash
1379
+ case base
1380
+ when String
1381
+ "#{base} #{append_hash(data).join(' ')}"
1382
+ when Hash
1383
+ base.merge(data)
1384
+ when Enumerable
1385
+ Set.new(base.to_a + append_hash(data)).to_a
1386
+ else
1387
+ data
1388
+ end
1389
+ when Enumerable
1390
+ case base
1391
+ when String
1392
+ "#{base} #{data.to_a.join(' ')}"
1393
+ when Hash
1394
+ "#{append_hash(base).join(' ')} #{data.to_a.join(' ')}"
1395
+ when Enumerable
1396
+ Set.new(base.to_a + data.to_a).to_a
1397
+ else
1398
+ data
1399
+ end
1400
+ else
1401
+ base
1402
+ end
1497
1403
  end
1498
1404
 
1499
1405
  def collect_hash(data, pass: [])
1500
1406
  ret = []
1501
- data.each { |key, val| ret += val unless pass.include?(key) }
1407
+ data.each { |key, val| ret.concat(val) unless pass.include?(key) }
1502
1408
  ret
1503
1409
  end
1504
1410
 
@@ -1512,6 +1418,15 @@ module Squared
1512
1418
  ret
1513
1419
  end
1514
1420
 
1421
+ def fetch_uri(*args, **kwargs, &blk)
1422
+ require 'open-uri'
1423
+ if RUBY_VERSION < '2.5'
1424
+ open(*args, **kwargs, &blk)
1425
+ else
1426
+ URI.open(*args, **kwargs, &blk)
1427
+ end
1428
+ end
1429
+
1515
1430
  def param_guard(action, flag, args: nil, key: nil, pat: nil, values: nil)
1516
1431
  if args && key
1517
1432
  val = args.fetch(key, nil)
@@ -1538,12 +1453,11 @@ module Squared
1538
1453
  end
1539
1454
  end
1540
1455
 
1541
- def relativepath(*files, all: false)
1542
- return [] if files.empty?
1456
+ def relativepath(*list, all: false)
1457
+ return [] if list.empty?
1543
1458
 
1544
- pat = /^#{Regexp.escape(File.join(path, ''))}/
1545
- files.flatten.map { |val| Pathname.new(val) }.select { |val| projectpath?(val) }.map do |val|
1546
- val = val.absolute? ? val.to_s.sub(pat, '') : val.to_s
1459
+ list.flatten.map! { |val| Pathname.new(val) }.select { |val| projectpath?(val) }.map! do |val|
1460
+ val = val.absolute? ? val.relative_path_from(path).to_s : val.to_s
1547
1461
  val = val[2..-1] if val.start_with?('./')
1548
1462
  val = "#{val}*" if all && val.end_with?('/')
1549
1463
  val
@@ -1552,11 +1466,11 @@ module Squared
1552
1466
 
1553
1467
  def projectmap(files, parent: false, pass: true)
1554
1468
  unless parent
1555
- project = files.select { |val| projectpath?(val) }
1556
- raise_error 'pathspec not within worktree' unless pass || files.size == project.size
1557
- files = project
1469
+ proj = files.select { |val| projectpath?(val) }
1470
+ raise_error 'pathspec not within worktree' unless pass || files.size == proj.size
1471
+ files = proj
1558
1472
  end
1559
- files.map { |val| val == '.' ? '.' : shell_quote(basepath(val.strip)) }
1473
+ files.map { |val| val == '.' ? '.' : shell_quote(basepath(val)) }
1560
1474
  end
1561
1475
 
1562
1476
  def semver(val)
@@ -1592,11 +1506,22 @@ module Squared
1592
1506
  end
1593
1507
 
1594
1508
  def colormap(val)
1595
- val.compact.map { |s| color(s) }.flatten
1509
+ val.compact.map! { |s| color(s) }.flatten
1596
1510
  end
1597
1511
 
1598
1512
  def epochtime
1599
- DateTime.now.strftime('%Q').to_i
1513
+ Time.now.strftime('%s%L').to_i
1514
+ end
1515
+
1516
+ def verbosetype
1517
+ case verbose
1518
+ when true
1519
+ 1
1520
+ when Numeric
1521
+ verbose.succ
1522
+ else
1523
+ 0
1524
+ end
1600
1525
  end
1601
1526
 
1602
1527
  def on(event, from, *args, **kwargs)
@@ -1740,13 +1665,14 @@ module Squared
1740
1665
  next if (items = @children.select { |item| item.task_include?(key) }).empty?
1741
1666
 
1742
1667
  ws.task_desc(@desc, action, 'workspace')
1743
- task task_join(action, 'workspace') => items.map { |item| task_join(item.name, action) }
1668
+ task task_join(action, 'workspace') => items.map! { |item| task_join(item.name, action) }
1744
1669
  end
1745
1670
  end
1746
1671
  end
1747
1672
 
1748
1673
  def projectpath?(val)
1749
- Pathname.new(val).absolute? ? val.to_s.start_with?(File.join(path, '')) : !val.to_s.start_with?('..')
1674
+ val = Pathname.new(val).cleanpath
1675
+ val.absolute? ? val.to_s.start_with?(File.join(path, '')) : !val.to_s.start_with?(File.join('..', ''))
1750
1676
  end
1751
1677
 
1752
1678
  def semmajor?(cur, want)
@@ -1766,11 +1692,8 @@ module Squared
1766
1692
  val.is_a?(Array) && val.all? { |p| p.is_a?(Proc) || p.is_a?(Method) }
1767
1693
  end
1768
1694
 
1769
- def session_arg?(*list, target: @session, value: false)
1770
- list.any? do |val|
1771
- pat = /^#{Regexp.escape(shell_option(val))}#{value ? '[ =].' : '(?:[ =]|$)'}/
1772
- target.any? { |opt| opt.match?(pat) }
1773
- end
1695
+ def session_arg?(*args, target: @session, **kwargs)
1696
+ !!target && OptionPartition.arg?(target, *args, **kwargs)
1774
1697
  end
1775
1698
 
1776
1699
  def from_sync?(*val)