squared 0.4.19 → 0.4.21

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7768e317ba03b32b5b8efeede15034c9c1c6bff1e6bca94e48119236a9647de4
4
- data.tar.gz: 592bca71ea7b863bfdbd8896e429688b1d7b38941e7eee14388eb868f6065486
3
+ metadata.gz: 4d8a1b2cbf68268501ff6e6d0c93376a695f65d5d39f3e54d51fc3782869080a
4
+ data.tar.gz: d79358deea9e25c69c7c1e43730109b9609bb52949b367f457c972166da38485
5
5
  SHA512:
6
- metadata.gz: 2eb5c090afe6a6514fa4f579e41f2f3136720cf4279d4d0464df8828e88b150e15245e5b69395abfe5af2b33f5850ca6ca9c379bd8970c4fd1e54125688e365e
7
- data.tar.gz: 5f537d9f3eb00dcfe5786092cf6752393a80b8caba758152a53e65e05f6222b89fd87959d094f2b9b1677cc4a65380ac3ade95dd204239fb5c51ab789bf1d6b4
6
+ metadata.gz: 40f3aca8a6df314ce47bfceb7df8c4dffd00a8c05953d4e68ee104f6f33bd15ec8dfcf4d12bc23490d545982376cad0fb4aa17797d3340e120f88ef55907fcfa
7
+ data.tar.gz: 24833ff7f8fc10a50760959bf421371049256df809bcf9a2fe742a3d2faf4f8608cb560cefc8cae7c40eabfcc3dbf579de03f46c836f6057a2d74266329ce75f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,51 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.21] - 2025-10-01
4
+
5
+ ### Added
6
+
7
+ - Project base method variable_set was aliased to the name apply.
8
+
9
+ ### Changed
10
+
11
+ - Project base method run visibility was changed to public.
12
+ - OptionPartition method uniq! returns self or nil.
13
+
14
+ ### Fixed
15
+
16
+ - Docker attribute file did not search for nearest config.
17
+ - Project task run did not accept Proc or Method definitions.
18
+ - Gem command options were revalidated to 3.7.2.
19
+ - Bundler command options were revalidated to 2.7.2.
20
+ - Ruby class method bundle did not pass through commands.
21
+ - Ruby task ruby did not separate options and arguments.
22
+ - Pip commands uninstall and freeze did not filter options.
23
+ - Ruby command gem action update did not append packages.
24
+ - OptionPartition did not detect short options with a merged value.
25
+ - Gem commands option version did not use quotes.
26
+ - Git command pull action all used undefined delete_prefix! method.
27
+ - OptionPartition did not delete added values from extras.
28
+ - Python editable projects can override requirements detection.
29
+ - Project session method did delete short options with a merged value.
30
+ - Gem command install did not try to resolve local paths.
31
+ - Ruby commands did not always check for file target exists.
32
+
33
+ ## [0.4.20] - 2025-09-14
34
+
35
+ ### Changed
36
+
37
+ - Project banners when requested return consistent arguments.
38
+
39
+ ### Fixed
40
+
41
+ - Workspace global as command alias used undefined parameter.
42
+ - Python did not separate dependency manager and build backend.
43
+ - Gem command build did not validate gemspec was located.
44
+ - Project class Ruby used glob methods not available in Ruby 2.4.
45
+ - Shell options support using boolean as values.
46
+ - Git command merge action commit failed when using interactive menu.
47
+ - NPM command line options did not support boolean flags.
48
+
3
49
  ## [0.4.19] - 2025-08-30
4
50
 
5
51
  ### Added
@@ -946,6 +992,8 @@
946
992
 
947
993
  - Changelog was created.
948
994
 
995
+ [0.4.21]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.21
996
+ [0.4.20]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.20
949
997
  [0.4.19]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.19
950
998
  [0.4.18]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.18
951
999
  [0.4.17]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.17-ruby
data/README.md CHANGED
@@ -105,9 +105,9 @@ Workspace::Application
105
105
  revbuild(include: %w[src/ framework/ types/]) # Synchronous is recommended
106
106
  end
107
107
  .add("squared/sqd", exclude: :git, pass: [:node, "checkout", "bump"]) do # Skip initialize(:node) + squared:checkout:* + squared:bump:*
108
- variable_set :script, "build:sqd" # Override detection
109
- variable_set :depend, false
110
- variable_set :clean, ["build/sqd/"]
108
+ apply :script, "build:sqd" # Override detection
109
+ apply :depend, false #
110
+ apply :clean, ["build/sqd/"] # variable_set (alias)
111
111
  end
112
112
  .with(:docker, only: ["build", "compose"]) do
113
113
  .add("squared", "docker", file: "Dockerfile", context: ".", tag: "latest", registry: "localhost:5000", username: "squared",
@@ -303,7 +303,7 @@ Workspace::Application
303
303
  doc(windows? ? ".\make.bat html" : "make html") # rake android-docs:doc | rake doc:python
304
304
  add("android-docs", "android", venv: "/home/user/.venv") # rake android-docs:depend
305
305
  add("chrome-docs", "chrome", graph: "android", venv: %w[.venv --clear]) do # /workspaces/chrome-docs/.venv
306
- variable_set :dependindex, 1 # Use Poetry for dependencies (optional)
306
+ apply :dependindex, 1 # Use Poetry for dependencies (optional)
307
307
  end
308
308
  end
309
309
  .with(:node) do
@@ -495,22 +495,23 @@ Most project classes will inherit from `Git` which enables these tasks:
495
495
 
496
496
  | Task | Git | Command |
497
497
  | :--------- | :--------------- | :-------------------------------------------- |
498
- | branch | branch | create set delete move copy list edit current |
498
+ | branch | branch | create track delete move copy list current |
499
499
  | checkout | checkout | commit branch track detach path |
500
500
  | commit | commit | add all amend amend-orig fixup |
501
- | diff | diff | head cached branch files between contain |
501
+ | diff | diff | head branch files view between contain |
502
502
  | fetch | fetch | origin remote all |
503
503
  | files | ls-files | cached modified deleted others |
504
- | git | | add blame clean mv rm revert status |
504
+ | git | | add blame clean mv revert rm status |
505
+ | log | log | view between contain |
505
506
  | merge | merge | commit no-commit send |
506
507
  | pull | pull | origin remote all |
507
508
  | rebase | rebase | branch onto send |
508
509
  | refs | ls-remote --refs | heads tags remote |
509
- | reset | reset | commit index patch mode |
510
- | restore | restore | staged worktree |
511
- | rev | rev | commit output |
512
- | show | show | format oneline |
513
- | stash | stash | push pop apply branch drop clear list all |
510
+ | reset | reset | commit index patch mode undo |
511
+ | restore | restore | source staged worktree |
512
+ | rev | rev | commit build output |
513
+ | show | show | format oneline textconv |
514
+ | stash | stash | push pop apply branch drop clear list |
514
515
  | submodule | submodule | status update branch url sync |
515
516
  | switch | switch | branch create detach |
516
517
  | tag | tag | add sign delete list |
@@ -597,6 +598,9 @@ BUILD_${NAME}_VERSION=0.1.0 # publish + detection
597
598
  BANNER=0 # hide banner
598
599
  BANNER_${NAME}=0 #
599
600
 
601
+ VERBOSE=0 # console output level
602
+ VERBOSE_${NAME}=0 # 0,1,2,n
603
+
600
604
  REVBUILD_FORCE=1 # Rebuild all targets
601
605
  REVBUILD_FORCE_${NAME}=1 # Rebuild project
602
606
 
@@ -639,7 +643,7 @@ GIT_AUTOSTASH_${NAME}=0 # rebase (project only)
639
643
  | :--------- | :---------------- | :-------------------------------------------------------------------- |
640
644
  | branch | create | TRACK=0,1,s F|FORCE |
641
645
  | branch | move copy | F|FORCE |
642
- | branch | set delete | COUNT=n |
646
+ | branch | delete | COUNT=n |
643
647
  | branch | global | SYNC |
644
648
  | checkout | branch | DETACH TRACK=s COUNT=n |
645
649
  | checkout | detach | REFLOG=1 |
@@ -189,7 +189,7 @@ module Squared
189
189
  emphasize(args, title: title + (subject ? " #{subject}" : ''), sub: sub, pipe: -1)
190
190
  else
191
191
  msg = [log_title(level, color: color)]
192
- msg << (color ? sub_style(subject, styles: (@theme && @theme[:subject]) || :bold) : subject) if subject
192
+ msg << (color ? sub_style(subject.to_s, styles: (@theme && @theme[:subject]) || :bold) : subject) if subject
193
193
  msg << args.shift if msg.size == 1
194
194
  message(msg.join(' '), *args, hint: hint)
195
195
  end
@@ -223,12 +223,8 @@ module Squared
223
223
  def emphasize(val, title: nil, footer: nil, right: false, cols: nil, sub: nil, pipe: nil,
224
224
  border: @theme && @theme[:border])
225
225
  n = 0
226
- max = ->(v) { n = [n, v.max_by(&:size).size].max }
227
- set = lambda do |v|
228
- ret = as_a(v, :to_s)
229
- max.call(ret)
230
- ret
231
- end
226
+ max = ->(a) { n = [n, a.max_by(&:size).size].max }
227
+ set = ->(s) { Array(s).map(&:to_s).tap { |a| max.call(a) } }
232
228
  title &&= set.call(title)
233
229
  footer &&= set.call(footer)
234
230
  if val.is_a?(::Array)
@@ -74,7 +74,7 @@ module Squared
74
74
  a = '--'
75
75
  b = '='
76
76
  end
77
- "#{a}#{flag}#{if val
77
+ "#{a}#{flag}#{unless val.nil?
78
78
  "#{b}#{if escape
79
79
  shell_escape(val, quote: quote, double: double, override: override)
80
80
  elsif quote
@@ -94,8 +94,8 @@ module Squared
94
94
 
95
95
  def shell_bin(name, env: true)
96
96
  key = name.upcase
97
- shell_quote((env && ENV["PATH_#{key}"]) || PATH[key] || PATH[key.to_sym] || name,
98
- option: false, force: false)
97
+ shell_quote((env && ENV["PATH_#{key}"]) || PATH[key] || PATH[key.to_sym] || name, option: false, force: false,
98
+ double: true)
99
99
  end
100
100
 
101
101
  def fill_option(val, **kwargs)
@@ -61,10 +61,9 @@ module Squared
61
61
  files.clear
62
62
  items.each do |file|
63
63
  if file.exist?
64
- if file.symlink?
65
- next unless force
66
- else
64
+ if !file.symlink?
67
65
  files << file
66
+ elsif !force
68
67
  next
69
68
  end
70
69
  end
@@ -213,7 +213,7 @@ module Squared
213
213
  ext[0] = mime
214
214
  elsif file
215
215
  keys.unshift(file)
216
- alt = basepath("#{main}.{#{ext.join(',')}}")
216
+ alt = basepath "#{main}.{#{ext.join(',')}}"
217
217
  file = Dir[alt].first
218
218
  else
219
219
  alt = main
@@ -346,8 +346,8 @@ module Squared
346
346
  basepath(file = main + @ext).to_s rescue file
347
347
  end
348
348
 
349
- def basepath(file)
350
- project ? project.basepath(file) : Pathname.new(file).realdirpath
349
+ def basepath(*args)
350
+ project ? project.basepath(*args) : Pathname.pwd.join(*args)
351
351
  end
352
352
  end
353
353
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.4.19'
4
+ VERSION = '0.4.21'
5
5
  end
@@ -629,7 +629,9 @@ module Squared
629
629
  end
630
630
 
631
631
  def home?
632
- !(proj = find(home)).nil? && proj.enabled?
632
+ return false unless (proj = find(home))
633
+
634
+ proj.enabled?
633
635
  end
634
636
 
635
637
  def windows?
@@ -9,6 +9,7 @@ module Squared
9
9
  module Workspace
10
10
  module Project
11
11
  class Base
12
+ include Comparable
12
13
  include Common::Format
13
14
  include System
14
15
  include Shell
@@ -16,7 +17,6 @@ module Squared
16
17
  include Utils
17
18
  include Support
18
19
  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 only exclude].freeze
@@ -83,6 +83,7 @@ module Squared
83
83
  @name = name.to_s.freeze
84
84
  @project = @path.basename.to_s.freeze
85
85
  @group = group&.to_s.freeze
86
+ @envname = env_key(@name).freeze
86
87
  @depend = kwargs[:depend]
87
88
  @doc = kwargs[:doc]
88
89
  @lint = kwargs[:lint]
@@ -98,7 +99,7 @@ module Squared
98
99
  @ref = []
99
100
  @children = []
100
101
  @events = hashobj.update({ first: first, last: last, error: error })
101
- @envname = env_key(@name).freeze
102
+ @as = hashobj
102
103
  @desc = (@name.include?(':') ? @name.split(':').join(ARG[:SPACE]) : @name).freeze
103
104
  @parent = nil
104
105
  @global = false
@@ -195,7 +196,7 @@ module Squared
195
196
  file &&= @workspace.home.join(env('LOG_DIR', ''), file).realdirpath
196
197
  rescue StandardError => e
197
198
  file = nil
198
- warn log_message(Logger::WARN, e) if warning?
199
+ print_error e
199
200
  end
200
201
  log[:progname] ||= @name
201
202
  if (val = env('LOG_LEVEL', ignore: false))
@@ -287,7 +288,7 @@ module Squared
287
288
  end
288
289
 
289
290
  def verbose=(val)
290
- @verbose = case val
291
+ @verbose = case (val = env('VERBOSE', val))
291
292
  when NilClass
292
293
  workspace.verbose
293
294
  when String
@@ -362,7 +363,7 @@ module Squared
362
363
  else
363
364
  force = args.fetch(:force, false)
364
365
  end
365
- unpack(path + dir, uri: tag, digest: digest, ext: ext, force: force)
366
+ unpack(basepath(dir), uri: tag, digest: digest, ext: ext, force: force)
366
367
  end
367
368
  end
368
369
  end
@@ -410,7 +411,6 @@ module Squared
410
411
  kwargs[:group] = group unless kwargs.key?(:group)
411
412
  kwargs[:ref] = ref unless kwargs.key?(:ref)
412
413
  parent = self
413
- proj = nil
414
414
  name = case name
415
415
  when String, Symbol
416
416
  name.to_s
@@ -419,10 +419,9 @@ module Squared
419
419
  end
420
420
  workspace.add(path, name, **kwargs) do
421
421
  __send__ :parent_set, parent
422
- proj = self
422
+ @children << self
423
+ instance_eval(&blk) if block_given?
423
424
  end
424
- @children << proj
425
- proj.instance_eval(&blk) if block_given?
426
425
  self
427
426
  end
428
427
 
@@ -436,7 +435,7 @@ module Squared
436
435
 
437
436
  out = obj.link(self, *args, **kwargs, &blk) if obj.respond_to?(:link)
438
437
  if !out
439
- warn log_message(Logger::WARN, 'link not compatible', subject: obj.to_s, hint: name)
438
+ print_error('link not compatible', subject: obj, hint: name)
440
439
  elsif out.respond_to?(:build)
441
440
  out.build
442
441
  end
@@ -476,7 +475,7 @@ module Squared
476
475
  else
477
476
  next unless respond_to?(:compose)
478
477
 
479
- cmd << a if (a = compose(as_get(b), d, script: true, args: e, from: from))
478
+ cmd << a if (a = compose(as_get(b, from), d, script: true, args: e, from: from))
480
479
  end
481
480
  var.merge!(c) if c.is_a?(Hash)
482
481
  end
@@ -484,8 +483,12 @@ module Squared
484
483
  else
485
484
  cmd, opts, var, flags, extra = args
486
485
  end
486
+ if cmd.is_a?(Proc) || cmd.is_a?(Method)
487
+ run_b(cmd, sync: sync, from: from)
488
+ return
489
+ end
487
490
  if cmd
488
- cmd = as_get cmd
491
+ cmd = as_get(cmd, from)
489
492
  opts = compose(opts, script: false) if opts && respond_to?(:compose)
490
493
  flags = append_hash(flags).join(' ') if flags.is_a?(Hash)
491
494
  case opts
@@ -502,7 +505,7 @@ module Squared
502
505
  else
503
506
  return unless (opts || extra) && respond_to?(:compose)
504
507
 
505
- cmd = compose(as_get(opts), flags, script: true, args: extra, from: from)
508
+ cmd = compose(as_get(opts, from), flags, script: true, args: extra, from: from)
506
509
  from = :script if from == :run && script?
507
510
  end
508
511
  run(cmd, var, sync: sync, from: from, banner: banner)
@@ -527,7 +530,7 @@ module Squared
527
530
  on_error(:prereqs, e, exception: true)
528
531
  end
529
532
  end
530
- warn log_message(Logger::WARN, name, 'method not found', subject: 'prereqs', hint: meth)
533
+ print_error(name, 'method not found', subject: 'prereqs', hint: meth)
531
534
  end
532
535
  elsif proj.build?
533
536
  proj.build(sync: sync)
@@ -582,7 +585,7 @@ module Squared
582
585
  else
583
586
  if @clean.is_a?(Enumerable) && !series?(@clean)
584
587
  @clean.each do |val|
585
- entry = path + (val = val.to_s)
588
+ entry = basepath(val = val.to_s)
586
589
  if entry.directory? && val.match?(%r{[\\/]\z})
587
590
  log&.warn "rm -rf #{entry}"
588
591
  rm_rf(entry, verbose: verbose)
@@ -715,7 +718,7 @@ module Squared
715
718
  delete = true
716
719
  end
717
720
  if create
718
- warn log_message(Logger::WARN, 'force remove', subject: name, hint: target)
721
+ print_error('force remove', subject: name, hint: target)
719
722
  target.rmtree
720
723
  target.mkpath
721
724
  end
@@ -788,9 +791,8 @@ module Squared
788
791
  end
789
792
 
790
793
  def as(cmd, script, to = nil)
791
- script = { "#{script}": to } if to
792
- data = (@as ||= {})[cmd.to_sym] ||= {}
793
- script.each { |key, val| data[key.to_s] = val }
794
+ data = @as[cmd.to_sym]
795
+ (to ? [[script, to]] : script).each { |key, val| data[key.to_s] = val }
794
796
  self
795
797
  end
796
798
 
@@ -807,6 +809,56 @@ module Squared
807
809
  self
808
810
  end
809
811
 
812
+ def run(cmd = @session, var = nil, exception: self.exception, sync: true, from: nil, banner: true, chdir: path,
813
+ interactive: nil, hint: nil, **)
814
+ unless cmd
815
+ print_error('no command given', subject: project, hint: from || 'unknown', pass: true)
816
+ return
817
+ end
818
+ cmd = cmd.target if cmd.is_a?(OptionPartition)
819
+ if interactive && (!@session || !option('y'))
820
+ title, y = case interactive
821
+ when Array
822
+ interactive
823
+ when String
824
+ [interactive, 'N']
825
+ else
826
+ ['Run', 'Y']
827
+ end
828
+ yn = y == 'Y' ? 'Y/n' : 'y/N'
829
+ exit 1 unless confirm("#{title}? [#{sub_style(cmd.to_s, styles: theme[:inline])}] [#{yn}] ", y)
830
+ end
831
+ cmd = session_done cmd
832
+ log&.info cmd
833
+ on :first, from
834
+ begin
835
+ if cmd.match?(/\A[^:]+:[^:]/) && workspace.task_defined?(cmd)
836
+ log&.warn "ENV discarded: #{var}" if var
837
+ task_invoke(cmd, exception: exception, warning: warning?)
838
+ else
839
+ print_item format_banner(hint ? "#{cmd} (#{hint})" : cmd, banner: banner) if sync
840
+ if var != false && (pre = runenv)
841
+ case pre
842
+ when Hash
843
+ var = var.is_a?(Hash) ? pre.merge(var) : pre
844
+ when Enumerable
845
+ cmd = command(*pre.to_a, cmd)
846
+ else
847
+ cmd = command(pre, cmd)
848
+ end
849
+ end
850
+ args = var.is_a?(Hash) ? [var, cmd] : [cmd]
851
+ ret = shell(*args, chdir: chdir, exception: exception)
852
+ end
853
+ rescue StandardError => e
854
+ on_error(from, e, exception: true)
855
+ false
856
+ else
857
+ on :last, from
858
+ ret
859
+ end
860
+ end
861
+
810
862
  def variable_set(key, *args, **kwargs, &blk)
811
863
  if variables.include?(key) || blocks.include?(key)
812
864
  val = case args.size
@@ -856,6 +908,8 @@ module Squared
856
908
  self
857
909
  end
858
910
 
911
+ alias apply variable_set
912
+
859
913
  def enabled?(ref = nil, **)
860
914
  return false if ref && !ref?(ref)
861
915
 
@@ -966,7 +1020,7 @@ module Squared
966
1020
  path.parent.ascend.each do |dir|
967
1021
  target = dir.join(*args)
968
1022
  return target if target.exist?
969
- break if (ascend.is_a?(String) && dir.join(ascend).exist?) || workspace.root == dir || parent&.path == dir
1023
+ break if (ascend && dir.join(ascend).exist?) || workspace.root == dir || parent&.path == dir
970
1024
  end
971
1025
  ret
972
1026
  end
@@ -993,56 +1047,6 @@ module Squared
993
1047
  log_console(*args, pipe: kwargs[:pipe] || pipe)
994
1048
  end
995
1049
 
996
- def run(cmd = @session, var = nil, exception: self.exception, sync: true, from: nil, banner: true, chdir: path,
997
- interactive: nil, hint: nil, **)
998
- unless cmd
999
- warn log_message(Logger::WARN, 'no command given', subject: project, hint: from || 'unknown', pass: true)
1000
- return
1001
- end
1002
- cmd = cmd.target if cmd.is_a?(OptionPartition)
1003
- if interactive && (!@session || !option('y'))
1004
- title, y = case interactive
1005
- when Array
1006
- interactive
1007
- when String
1008
- [interactive, 'N']
1009
- else
1010
- ['Run', 'Y']
1011
- end
1012
- yn = y == 'Y' ? 'Y/n' : 'y/N'
1013
- exit 1 unless confirm("#{title}? [#{sub_style(cmd.to_s, styles: theme[:inline])}] [#{yn}] ", y)
1014
- end
1015
- cmd = session_done cmd
1016
- log&.info cmd
1017
- on :first, from
1018
- begin
1019
- if cmd.match?(/\A[^:]+:[^:]/) && workspace.task_defined?(cmd)
1020
- log&.warn "ENV discarded: #{var}" if var
1021
- task_invoke(cmd, exception: exception, warning: warning?)
1022
- else
1023
- print_item format_banner(hint ? "#{cmd} (#{hint})" : cmd, banner: banner) if sync
1024
- if var != false && (pre = runenv)
1025
- case pre
1026
- when Hash
1027
- var = var.is_a?(Hash) ? pre.merge(var) : pre
1028
- when Enumerable
1029
- cmd = command(*pre.to_a, cmd)
1030
- else
1031
- cmd = command(pre, cmd)
1032
- end
1033
- end
1034
- args = var.is_a?(Hash) ? [var, cmd] : [cmd]
1035
- ret = shell(*args, chdir: chdir, exception: exception)
1036
- end
1037
- rescue StandardError => e
1038
- on_error(from, e, exception: true)
1039
- false
1040
- else
1041
- on :last, from
1042
- ret
1043
- end
1044
- end
1045
-
1046
1050
  def run_s(*cmd, env: nil, sync: true, from: nil, banner: verbose != false, **kwargs)
1047
1051
  on :first, from
1048
1052
  begin
@@ -1241,15 +1245,7 @@ module Squared
1241
1245
  end
1242
1246
 
1243
1247
  def session_delete(*args, target: @session)
1244
- ret = []
1245
- args.each do |val|
1246
- pat = /\A#{Regexp.escape(shell_option(val))}(?: |=|\z)/
1247
- if (key = target.find { |opt| opt.match?(pat) })
1248
- target.delete(key)
1249
- ret << key
1250
- end
1251
- end
1252
- ret
1248
+ OptionPartition.delete(target, *args)
1253
1249
  end
1254
1250
 
1255
1251
  def session_output(*cmd, **kwargs)
@@ -1295,8 +1291,8 @@ module Squared
1295
1291
  puts 'Success'
1296
1292
  end
1297
1293
 
1298
- def print_error(err, loglevel: Logger::WARN, pass: false)
1299
- warn log_message(loglevel, err, pass: pass) if warning?
1294
+ def print_error(*args, loglevel: Logger::WARN, **kwargs)
1295
+ warn log_message(loglevel, *args, **kwargs) if warning?
1300
1296
  end
1301
1297
 
1302
1298
  def print_item(*val)
@@ -1467,7 +1463,7 @@ module Squared
1467
1463
  next if (key = key.to_s).start_with?('__')
1468
1464
 
1469
1465
  if val.nil? || extra || session_arg?(key, target: target)
1470
- session_delete(key, target: target)
1466
+ OptionPartition.delete_key(target, key)
1471
1467
  next if val.nil?
1472
1468
  end
1473
1469
  case val
@@ -1601,7 +1597,7 @@ module Squared
1601
1597
  raise_error("invalid JSON #{kind.name}", val, hint: hint) if kind && !ret.is_a?(kind)
1602
1598
  rescue StandardError => e
1603
1599
  log&.warn e
1604
- warn log_message(Logger::WARN, e, subject: name) if warning?
1600
+ print_error(e, subject: name)
1605
1601
  else
1606
1602
  ret
1607
1603
  end
@@ -1739,7 +1735,7 @@ module Squared
1739
1735
  raise_error 'pathspec not within worktree' unless pass || files.size == proj.size
1740
1736
  files = proj
1741
1737
  end
1742
- files.map { |val| val == '.' ? '.' : shell_quote(path + val) }
1738
+ files.map { |val| val == '.' ? '.' : shell_quote(basepath(val)) }
1743
1739
  end
1744
1740
 
1745
1741
  def matchmap(list, prefix = nil)
@@ -2006,14 +2002,12 @@ module Squared
2006
2002
 
2007
2003
  def dependfile_set(list)
2008
2004
  @dependindex = list.index { |file| basepath(file).exist? }.tap do |index|
2009
- @dependfile = @path + list[index || 0]
2005
+ @dependfile = basepath(list[index || 0])
2010
2006
  end
2011
2007
  end
2012
2008
 
2013
- def as_get(val)
2014
- return unless val
2015
-
2016
- @global && (ret = @as && @as[from] && @as[from][val]) ? ret : val
2009
+ def as_get(val, from)
2010
+ (@global && @as[from][val]) || val
2017
2011
  end
2018
2012
 
2019
2013
  def task_build(keys)