squared 0.6.17 → 0.6.19

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: 2390f7c0bb110d16dd19ad08cd75e166953b9cccf7c57215301ae997fd05bbe2
4
- data.tar.gz: e91ec4e023247fd9ce4faf5e4f95a8b2723f801fd2b15bccd47ba7c519c674da
3
+ metadata.gz: ebf207dc466cef74e15ff2d1af3918d40f2d11f284c968662dacd705560a5c2b
4
+ data.tar.gz: abc405b0b839704fa1d0d52116f3e58ce32f02851c399b5126ad934b37e07572
5
5
  SHA512:
6
- metadata.gz: b53882da825e403432228e0e83aa152ffb4846ae6a1f73a49b26ffc796b16c6cd78dcaafd356a39c26c96c77370c7a644bd20ca9329493dd6eeee4bc90323fd5
7
- data.tar.gz: 2117e0d6c0bdcb1c31ad6acdf6aaa05322abe820060dd76683a93ed8d96f7c0b9183d37db5ca3df55949b852b83ea4713c9f7d99158ac44de1c1433102c0960e
6
+ metadata.gz: 81b918aab70520897e8b6894aeb6714ab6ede54d5cb11c907b2bb87ff595a0b62b782f6e848ea7b69bab0b88f4a6b6d05f5e28ca18af40c561db7e9cb75e8ded
7
+ data.tar.gz: 48edbabfd70cc21e8dad5db4d8f916d7c5875d94f6dcd5c60cfb974f5dee5f953cd210f1c06e2147d995655551125f51404ea386ee0354af285d0b5bb14035ec
data/CHANGELOG.md CHANGED
@@ -1,5 +1,61 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.6.19] - 2026-09-23
4
+
5
+ ### Fixed
6
+
7
+ - See `0.4.42`.
8
+
9
+ ## [0.5.27] - 2026-09-23
10
+
11
+ ### Fixed
12
+
13
+ - See `0.4.42`.
14
+
15
+ ## [0.4.42] - 2026-09-23
16
+
17
+ ### Fixed
18
+
19
+ - OptionPartition did not strip pre-existing quotes when parsing options.
20
+ - Node command outdated did not strip styling from semver in package.json.
21
+ - Git command show did not recognize object names.
22
+ - Docker destination mounts that are not absolute are treated as errors.
23
+ - Docker source mounts for any named volumes or images were inoperable.
24
+
25
+ ## [0.6.18] - 2026-09-04
26
+
27
+ ### Added
28
+
29
+ - Docker command bake action buildx with first arg "-" inherits base args.
30
+
31
+ ### Fixed
32
+
33
+ - Git action grep did not recognize format and max-count.
34
+ - Node command nvm did not quote executable path.
35
+
36
+ ## [0.5.26] - 2026-09-04
37
+
38
+ ### Fixed
39
+
40
+ - Node command nvm did not quote executable path.
41
+
42
+ ## [0.4.41] - 2026-09-04
43
+
44
+ ### Added
45
+
46
+ - Common base argument SUCCESS for command confirmation was created.
47
+
48
+ ### Changed
49
+
50
+ - Program options prefer using quotes instead of escape.
51
+ - Docker container run arguments with a leading dash are concatenated.
52
+
53
+ ### Fixed
54
+
55
+ - Common prompt method choice did not grep list items.
56
+ - OptionPartition static method strip did not parse flags with dashes.
57
+ - Project base method choice_index did not support multiple selections.
58
+
3
59
  ## [0.6.17] - 2026-08-06
4
60
 
5
61
  ### Added
@@ -294,7 +350,7 @@
294
350
 
295
351
  ### Fixed
296
352
 
297
- - See `0.5.18`.
353
+ - See `0.4.32`.
298
354
 
299
355
  ## [0.4.32] - 2025-11-25
300
356
 
@@ -1757,6 +1813,8 @@
1757
1813
 
1758
1814
  - Changelog was created.
1759
1815
 
1816
+ [0.6.19]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.19
1817
+ [0.6.18]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.18
1760
1818
  [0.6.17]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.17
1761
1819
  [0.6.16]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.16
1762
1820
  [0.6.15]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.15
@@ -1775,6 +1833,8 @@
1775
1833
  [0.6.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.2
1776
1834
  [0.6.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.1
1777
1835
  [0.6.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.0
1836
+ [0.5.27]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.27
1837
+ [0.5.26]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.26
1778
1838
  [0.5.25]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.25
1779
1839
  [0.5.24]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.24
1780
1840
  [0.5.23]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.23
@@ -1801,6 +1861,8 @@
1801
1861
  [0.5.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.2-ruby
1802
1862
  [0.5.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.1-ruby
1803
1863
  [0.5.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.0-ruby
1864
+ [0.4.42]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.42
1865
+ [0.4.41]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.41
1804
1866
  [0.4.40]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.40
1805
1867
  [0.4.39]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.39
1806
1868
  [0.4.38]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.38
@@ -14,6 +14,7 @@ module Squared
14
14
  CHOICE: 25,
15
15
  QUOTE: "'",
16
16
  SPACE: ' => ',
17
+ SUCCESS: 'Success',
17
18
  GRAPH: %w[| - | \\ -].freeze,
18
19
  BORDER: %w[| - - - - - | | - -].freeze,
19
20
  VIEW: 'view',
@@ -56,11 +56,12 @@ module Squared
56
56
  def choice(msg, list = nil, min: 1, max: 1, multiple: false, index: false, grep: nil, border: nil, auto: true,
57
57
  force: true, attempts: 3, timeout: 0)
58
58
  require 'timeout'
59
+ multiple = Array(multiple) if multiple.is_a?(::Numeric)
59
60
  if list
60
61
  grep &&= Array(grep).map { |val| Regexp.new(val) }
61
62
  items = []
62
63
  list.each do |val|
63
- next if grep&.none? { |pat| pat.match?(line) }
64
+ next if grep&.none? { |pat| pat.match?(val) }
64
65
 
65
66
  items << val.to_s.chomp
66
67
  puts '%2d. %s' % [items.size, val]
@@ -77,7 +78,7 @@ module Squared
77
78
  puts print_footer(border: border)
78
79
  end
79
80
  msg = "#{msg + (force ? ':' : '?')} [#{min}-#{max}#{if (n = multiple)
80
- "|,#{n.is_a?(::Numeric) ? "{#{n}}" : '*'}"
81
+ "|,#{n.is_a?(::Array) ? "{#{n.join(',')}}" : '*'}"
81
82
  end}] "
82
83
  end
83
84
  end
@@ -106,8 +107,8 @@ module Squared
106
107
  k.flatten!
107
108
  k.uniq!
108
109
  k.sort!
109
- unless multiple.is_a?(::Numeric) && multiple != k.size
110
- return index || !items ? k : k.map! { |i| items[i.pred] }
110
+ unless multiple.is_a?(::Array) && !multiple.include?(k.size)
111
+ return index || !items ? k : k.map { |i| items[i.pred] }
111
112
  end
112
113
  end
113
114
  elsif between.call(ch)
@@ -136,7 +136,7 @@ module Squared
136
136
  end
137
137
 
138
138
  def env_key(*val)
139
- val.join('_').gsub(/\W+/, '_').upcase
139
+ val.join('_').sub(/\A\d+\W*/, '__').gsub(/\W+/, '_').upcase
140
140
  end
141
141
 
142
142
  def env_value(key, default = '', suffix: nil, strict: false)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.6.17'
4
+ VERSION = '0.6.19'
5
5
  end
@@ -1532,7 +1532,7 @@ module Squared
1532
1532
  end
1533
1533
 
1534
1534
  def print_success
1535
- puts 'Success'
1535
+ puts ARG[:SUCCESS]
1536
1536
  end
1537
1537
 
1538
1538
  def print_error(*args, loglevel: Logger::WARN, **kwargs)
@@ -1969,7 +1969,10 @@ module Squared
1969
1969
  if accept
1970
1970
  hint = Array(ret).map { |val| sub_style(val.to_s, theme[:inline]) }.join(', ')
1971
1971
  accept = Array(accept).map { |val| Array(val) }
1972
- ret = Array(ret) if accept.any? { |val| val[1] == true }
1972
+ if accept.any? { |val| val[1] == true }
1973
+ ret = [ret]
1974
+ multiple = -1
1975
+ end
1973
1976
  loop do
1974
1977
  item = accept.first
1975
1978
  c = confirm("#{item[0]}#{" [#{hint}]" if hint}", item[2] ? 'Y' : 'N')
@@ -1985,7 +1988,7 @@ module Squared
1985
1988
  exit 1 unless accept.empty?
1986
1989
  end
1987
1990
  if values
1988
- ret = Array(ret)
1991
+ ret = [ret] unless accept && multiple == -1
1989
1992
  Array(values).each do |val|
1990
1993
  if val.is_a?(Array)
1991
1994
  val, force = val
@@ -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=q call=b? f|file=p metadata-file=p progress=b provenance=q
20
- sbom=q].freeze
19
+ shared: %w[check load no-cache pull push allow=qq call=b? f|file=p metadata-file=p progress=b provenance=b?
20
+ sbom=b?].freeze
21
21
  }.freeze,
22
22
  compose: {
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,
23
+ common: %w[1 all-resources compatibility dry-run ansi=b env-file=p f|file=p parallel=n profile=b progress=b
24
+ project-directory=p p|project-name=b].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-TTY=b? user=e w|workdir=q].freeze,
28
+ exec: %w[d|detach privileged e|env=qq index=i T|no-tty=!? user=b 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-TTY=b? p|publish=q pull=b u|user=e v|volume=q w|workdir=q].freeze,
31
+ T|no-tty=!? p|publish=q pull=b u|user=b v|volume=qq 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
@@ -37,9 +37,9 @@ module Squared
37
37
  }.freeze,
38
38
  container: {
39
39
  create: %w[init i|interactive no-healthcheck oom-kill-disable privileged P|publish-all q|quiet read-only
40
- rm t|tty use-api-socket add-host=q annotation=q a|attach=b blkio-weight=i blkio-weight-device=i
41
- cap-add=b cap-drop=b cgroup-parent=b cgroupns=b cidfile=p device=q device-cgroup-rule=q
42
- device-read-bps=q device-read-iops=q device-write-bps=q device-write-iops=q
40
+ rm t|tty=!? use-api-socket add-host=q annotation=q a|attach=b blkio-weight=i
41
+ blkio-weight-device=i cap-add=b cap-drop=b cgroup-parent=b cgroupns=b cidfile=p device=q
42
+ device-cgroup-rule=q device-read-bps=q device-read-iops=q device-write-bps=q device-write-iops=q
43
43
  dns=q dns-option=q dns-search=q domainname=b entrypoint=q e|env=qq env-file=p expose=q gpus=q
44
44
  group-add=b health-cmd=q health-interval=b health-retries=i health-start-interval=q
45
45
  health-start-period=q health-timeout=q hostname=q io-maxbandwidth=b io-maxiops=b ip=b ip6=q ipc=b
@@ -47,13 +47,14 @@ module Squared
47
47
  m|memory=b memory-reservation=b memory-swap=n memory-swappiness=n mount=qq name=b network=b
48
48
  network-alias=b oom-score-adj=b pid=b pids-limit=n platform=q p|publish=q pull=b restart=b
49
49
  runtime=b security-opt=q shm-size=b stop-signal=b stop-timeout=i storage-opt=q sysctl=q tmpfs=q
50
- ulimit=q u|user=b userns=b uts=b v|volume=q volume-driver=b volumes-from=b w|workdir=q].freeze,
50
+ ulimit=q u|user=b userns=b uts=b v|volume=qq volume-driver=b volumes-from=b w|workdir=q].freeze,
51
51
  run: %w[d|detach detach-keys=q sig-proxy=b?].freeze,
52
52
  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
53
53
  cpuset-cpus=b cpuset-mems=b m|memory=b memory-reservation=b memory-swap=n pids-limit=n
54
54
  restart=q].freeze,
55
- exec: %w[d|detach i|interactive privileged t|tty detach-keys=q e|env=qq env-file=p u|user=e
55
+ exec: %w[d|detach i|interactive privileged t|tty=!? detach-keys=q e|env=qq env-file=p u|user=b
56
56
  w|workdir=q].freeze,
57
+ rm: %w[f|force l|link v|volumes].freeze,
57
58
  commit: %w[no-pause a|author=q c|change=q m|message=q pause=b?].freeze,
58
59
  inspect: %w[s|size f|format=q type=b].freeze,
59
60
  start: %w[a|attach i|interactive detach-keys=q].freeze,
@@ -76,10 +77,10 @@ module Squared
76
77
  VAL_DOCKER = {
77
78
  run: {
78
79
  common: %w[source src destination dst target readonly ro].freeze,
79
- bind: %w[bind-propagation].freeze,
80
+ bind: %w[bind-create-src bind-propagation].freeze,
80
81
  volume: %w[volume-subpath volume-nocopy volume-opt].freeze,
81
82
  tmpfs: %w[tmpfs-size tmpfs-mode].freeze,
82
- image: %w[image-path].freeze
83
+ image: %w[image-subpath].freeze
83
84
  }.freeze,
84
85
  ls: {
85
86
  compose: %w[Name Image Command Service RunningFor Status Ports CreatedAt ExitCode Health ID Labels
@@ -393,6 +394,10 @@ module Squared
393
394
  append_tag(tag || option('tag', ignore: false) || self.tag)
394
395
  append_context context
395
396
  when :bake
397
+ if op.first == '-'
398
+ op.shift
399
+ op << @output[4] if @output[4]
400
+ end
396
401
  unless op.empty?
397
402
  if !context && op.size > 1 && basepath(op.last).directory?
398
403
  pat = /\btarget\s+"#{Regexp.escape(op.last)}"/
@@ -484,20 +489,30 @@ module Squared
484
489
  end
485
490
  end
486
491
  case k
487
- when 'readonly', 'ro'
488
- args << k
492
+ when 'readonly', 'ro', 'volume-nocopy', 'bind-create-src'
493
+ args << k if %w[bind volume].include?(type)
489
494
  next
490
- when 'source', 'src', 'destination', 'dst', 'target', 'volume-subpath', 'image-path'
491
- v = basepath v
495
+ when 'source', 'src', 'destination', 'dst', 'target', 'volume-subpath', 'image-subpath'
496
+ raise_error ArgumentError, "no path value: #{k}", hint: flag unless v
497
+ case k
498
+ when 'source', 'src'
499
+ if type == 'bind'
500
+ v = basepath v
501
+ elsif type == 'tmpfs'
502
+ next
503
+ end
504
+ when 'destination', 'dst', 'target'
505
+ puts log_message("path is not absolute: #{v}", subject: from, hint: k) unless v.start_with?('/')
506
+ end
492
507
  v = shell_quote(v, option: false, force: false) if q == ''
493
508
  end
494
509
  args << "#{k}=#{q + v + q}"
495
510
  elsif !silent?
496
- log_message('unrecognized option', subject: from, hint: k)
511
+ puts log_message('unrecognized option', subject: from, hint: k)
497
512
  end
498
513
  end
499
514
  raise_error TypeError, 'none specified', hint: flag unless type
500
- cmd << "--mount type=#{type},#{args.join(',')}"
515
+ op << "--mount type=#{type},#{args.join(',')}"
501
516
  end
502
517
  end
503
518
  append_command(flag, id || tagmain, op.extras)
@@ -506,7 +521,7 @@ module Squared
506
521
  op.append(escape: true, strip: /^:/)
507
522
  when :commit
508
523
  latest = op.shift || tagmain
509
- cmd << id << latest
524
+ op << id << latest
510
525
  raise_error ArgumentError, "unrecognized args: #{op.join(', ')}", hint: flag unless op.empty?
511
526
  return unless confirm_command(cmd.to_s, title: from, target: id, as: latest)
512
527
 
@@ -527,7 +542,7 @@ module Squared
527
542
  else
528
543
  if op.empty?
529
544
  ps, status, no = filter_ps flag, from
530
- cmd << '--no-stream' if flag == :stats
545
+ op << '--no-stream' if flag == :stats
531
546
  list_image(flag, ps, no: no, hint: status, from: from) { |img| run(cmd.temp(img), from: from) }
532
547
  return
533
548
  end
@@ -703,8 +718,22 @@ module Squared
703
718
  when :exec
704
719
  raise_error ArgumentError, 'nothing to execute', hint: flag if list.empty?
705
720
  end
706
- target << val << list.shift
707
- target << list.join(' && ') unless list.empty?
721
+ target << val
722
+ case list.first
723
+ when '--'
724
+ target.merge(list.drop(1))
725
+ when /\A(--|&&)(\s|\z)/
726
+ target.merge(list)
727
+ else
728
+ target << list.shift
729
+ unless list.empty?
730
+ if list.first.start_with?('-')
731
+ target.merge(list)
732
+ else
733
+ target << list.join(' && ')
734
+ end
735
+ end
736
+ end
708
737
  end
709
738
 
710
739
  def append_file(type, target: @session, index: 2)
@@ -923,7 +952,7 @@ module Squared
923
952
  end
924
953
  cmd.merge(Array(out).map! { |val| val.split(/\s+/, 2).first })
925
954
  cmd << args
926
- success?(run(cmd), ctx.start_with?(/network|tag|save/))
955
+ success?(run(cmd, { 'NO_COLOR' => 'true' }), ctx.start_with?(/network|tag|save/))
927
956
  end
928
957
 
929
958
  def filetype(val = dockerfile)
@@ -169,9 +169,10 @@ module Squared
169
169
  fetch: {
170
170
  base: %w[multiple porcelain progress P|prune-tags refetch stdin u|update-head-ok
171
171
  recurse-submodules-default=b?].freeze,
172
- pull: %w[4 6 n t a|append atomic dry-run f|force k|keep negotiate-only prefetch p|prune q|quiet set-upstream
173
- unshallow update-shallow v|verbose deepen=i depth=i j|jobs=i negotiation-tip=q recurse-submodules=v
174
- refmap=q o|server-option=q shallow-exclude=b shallow-since=v upload-pack=q].freeze
172
+ pull: %w[n t 4|ipv4 6|ipv6 a|append atomic dry-run f|force k|keep negotiate-only prefetch p|prune q|quiet
173
+ set-upstream unshallow update-shallow v|verbose deepen=i depth=i j|jobs=i negotiation-tip=q
174
+ recurse-submodules=v refmap=q o|server-option=q shallow-exclude=b shallow-since=v
175
+ upload-pack=q].freeze
175
176
  }.freeze,
176
177
  git: {
177
178
  add: %w[N|intent-to-add].freeze,
@@ -210,7 +211,7 @@ module Squared
210
211
  ita-invisible-in-index minimal name-only name-status no-color-moved-ws no-prefix no-renames numstat
211
212
  patch-with-raw patch-with-stat patience pickaxe-all pickaxe-regex raw shortstat summary a|text
212
213
  abbrev=i? anchored=q break-rewrites=b? color=b color-moved=b color-moved-ws=b color-words=q?
213
- diff-algorithm=b diff-filter=e? X|dirstat=b? dirstat-by-file=b? dst-prefix=q find-copies=i?
214
+ diff-algorithm=b diff-filter=q? X|dirstat=b? dirstat-by-file=b? dst-prefix=q find-copies=i?
214
215
  find-object=b find-renames=b? ignore-matching-lines=q ignore-submodules=b? line-prefix=q output=p
215
216
  output-indicator-context=q output-indicator-new=q output-indicator-old=q relative=p rotate-to=p
216
217
  skip-to=p src-prefix=q stat=b? stat-count=i stat-width=i stat-name-width=i submodule=b?
@@ -268,7 +269,7 @@ module Squared
268
269
  checkout: %w[overwrite-ignore guess overlay progress recurse-submodules track].freeze,
269
270
  fetch: {
270
271
  base: %w[auto-gc auto-maintenance write-commit-graph write-fetch-head].freeze,
271
- pull: %w[all ipv4 ipv6 recurse-submodules show-forced-updates tags].freeze
272
+ pull: %w[all recurse-submodules show-forced-updates tags].freeze
272
273
  },
273
274
  grep: %w[color exclude-standard recursive textconv].freeze,
274
275
  log: {
@@ -586,10 +587,10 @@ module Squared
586
587
  when 'i', 'E', 'F', 'P'
587
588
  opts << last
588
589
  else
589
- if last =~ /^(f(-ormat)?)=(.+)$/
590
+ if last =~ /^f(?:-ormat)?=(.+)$/
590
591
  opts.shift
591
592
  opts << "format=#{$1}"
592
- elsif last =~ /^(max(-count)?)=(\d+)$/
593
+ elsif last =~ /^max(?:-count)?=(\d+)$/
593
594
  opts << "max-count=#{$1}"
594
595
  else
595
596
  grep << last
@@ -1726,7 +1727,7 @@ module Squared
1726
1727
  cmd << '--textconv'
1727
1728
  append_value(files.flat_map { |val| Dir[val] }
1728
1729
  .select { |val| projectpath?(val) }
1729
- .map! { |val| shell_quote("HEAD:#{val}") })
1730
+ .map! { |val| "HEAD:#{val}" })
1730
1731
  source(banner: false)
1731
1732
  return
1732
1733
  when :oneline
@@ -1740,11 +1741,11 @@ module Squared
1740
1741
  else
1741
1742
  opts << format if format
1742
1743
  end
1743
- list = OPT_GIT[:show] + OPT_GIT[:diff][:show] + OPT_GIT[:log][:diff] + OPT_GIT[:log][:diff_context]
1744
+ list = OPT_GIT[:show] + OPT_GIT[:diff][:show] + collect_hash(OPT_GIT[:log], pass: [:base])
1744
1745
  op = OptionPartition.new(opts, list, cmd,
1745
1746
  project: self,
1746
1747
  no: OPT_GIT[:no][:show] + collect_hash(OPT_GIT[:no][:log], pass: [:base]))
1747
- op.append(delim: true)
1748
+ op.append
1748
1749
  source(exception: false, banner: flag != :oneline)
1749
1750
  end
1750
1751
 
@@ -1775,7 +1776,7 @@ module Squared
1775
1776
  op.add_quote(remote) if remote
1776
1777
  out, banner, from = source(io: true)
1777
1778
  print_item banner
1778
- ret = write_lines(out, grep: op.extras, prefix: "refs/#{flag}/")
1779
+ ret = write_lines(out, grep: op.extras)
1779
1780
  list_result(ret, flag.to_s, grep: op.extras, banner: banner, from: from)
1780
1781
  end
1781
1782
 
@@ -1798,7 +1799,7 @@ module Squared
1798
1799
  when :revert
1799
1800
  list.concat(VAL_GIT[:rebase][:send])
1800
1801
  end
1801
- op = OptionPartition.new(opts, list, cmd, project: self, no: OPT_GIT[:no][flag], single: /\A\d+\z/,
1802
+ op = OptionPartition.new(opts, list, cmd, project: self, no: OPT_GIT[:no][flag],
1802
1803
  first: case flag
1803
1804
  when :blame, :revert then nil
1804
1805
  else matchpathspec
@@ -267,7 +267,7 @@ module Squared
267
267
  version = param_guard(action, 'version', args: args, key: :version)
268
268
  args = args.extras
269
269
  args << readline('Enter command', force: true) if args.empty?
270
- args.unshift(File.join(ENV['NVM_DIR'], 'nvm-exec'))
270
+ args.unshift(shell_quote(File.join(ENV['NVM_DIR'], 'nvm-exec')))
271
271
  run(args.join(' '), { 'NODE_VERSION' => version }, banner: false, from: :nvm)
272
272
  end
273
273
  when 'pack'
@@ -777,17 +777,17 @@ module Squared
777
777
  end
778
778
  a = a.ljust(col1)
779
779
  b = b.ljust(col2)
780
- sub_style! b, theme[:current] if theme[:current] && !stdin?
780
+ b = sub_style b, theme[:current] if theme[:current] && !stdin?
781
781
  if cur == -1
782
782
  c = 'SKIP'
783
783
  elsif modified == cur
784
784
  c = 'FAIL'
785
785
  elsif !stdin?
786
786
  if d == 1
787
- sub_style! a, theme[:major]
788
- sub_style! c, :bold, color(:green)
787
+ a = sub_style a, theme[:major]
788
+ c = sub_style c, :bold, color(:green)
789
789
  else
790
- sub_style!(c, **opt_style(color(d == 3 ? :green : :yellow), SEM_VER, d))
790
+ c = sub_style(c, **opt_style(color(d == 3 ? :green : :yellow), SEM_VER, d))
791
791
  end
792
792
  g = item
793
793
  end
@@ -860,8 +860,8 @@ module Squared
860
860
  b = sub_style b.ljust(col2), color(d ? :red : :yellow)
861
861
  c = c.ljust(col3)
862
862
  unless d
863
- sub_style! a, theme[:active]
864
- sub_style! c, color(:green)
863
+ a = sub_style a, theme[:active]
864
+ c = sub_style c, color(:green)
865
865
  pending += 1
866
866
  end
867
867
  puts "#{pad.call(i, avail)}. #{(a + c + b).subhint(d ? 'locked' : 'latest')}"
@@ -651,7 +651,7 @@ module Squared
651
651
  op.clear(pass: false)
652
652
  else
653
653
  if op.empty?
654
- op << "#{dist.call}/*"
654
+ op.add_path(dist.call, '*')
655
655
  else
656
656
  op.add_path
657
657
  end
@@ -88,8 +88,25 @@ module Squared
88
88
 
89
89
  def strip(val)
90
90
  val = shell_split val if val.is_a?(String)
91
- Array(val).map { |s| s.sub(OPT_SINGLE, '\1=\2').sub(OPT_VALUE, '\1=\2').sub(OPT_NAME, '\2') }
92
- .reject(&:empty?)
91
+ ret = []
92
+ pass = -1
93
+ (args = Array(val)).each_with_index do |s, i|
94
+ next if s.empty? || pass == i
95
+
96
+ if s == '--'
97
+ ret << s << args[i.succ..-1].join(' ')
98
+ break
99
+ end
100
+ next ret << s unless s.start_with?('-')
101
+
102
+ if !s.include?('=') && (j = args[i.succ]) && !j.start_with?('-')
103
+ ret << "#{s.sub(/^-{1,2}/, '')}=#{j}"
104
+ pass = i.succ
105
+ else
106
+ ret << s.sub(OPT_SINGLE, '\1=\2').sub(OPT_VALUE, '\1=\2').sub(OPT_NAME, '\2')
107
+ end
108
+ end
109
+ ret
93
110
  end
94
111
 
95
112
  def select(list, bare: true, no: true, single: false, double: false)
@@ -141,7 +158,11 @@ module Squared
141
158
  end
142
159
 
143
160
  def pattern?(val)
144
- val.match?(/\A\^|\$\z/) || val.match?(/[.)][*+?]|\(\?:|\\[dsw\d]|\[.+\]|\{\d+,?\d*\}/i)
161
+ Regexp.new(val)
162
+ val.start_with?('\A', '^') || val.end_with?('\z', '$') ||
163
+ val.match?(/[.)][*+?]|\(\?[:=!><]|\\[dsw\d]|\[.+\]|\{\d+,?\d*\}/i)
164
+ rescue RegexpError
165
+ false
145
166
  end
146
167
 
147
168
  private
@@ -282,7 +303,7 @@ module Squared
282
303
  end
283
304
  numtype = [
284
305
  [i, /\A\d+\z/],
285
- [f, /\A\d*(?:\.\d+)?\z/],
306
+ [f, /\A(\d+(\.\d*)?|\d*\.\d+)\z/],
286
307
  [si, /\A-?\d+\z/]
287
308
  ].freeze
288
309
  numcheck = ->(k, v) { numtype.any? { |flag, pat| flag.include?(k) && v.match?(pat) } }
@@ -311,23 +332,27 @@ module Squared
311
332
  if opt =~ OPT_VALUE
312
333
  key = $1
313
334
  val = $2
335
+ if val =~ /\A(["'])(.+)\1\z/
336
+ val = $2
337
+ double = $1 == '"'
338
+ end
314
339
  merge = m.include?(key)
315
340
  if e.include?(key)
316
- add shell_option(key, val, merge: merge, sep: sep)
341
+ add shell_option(key, val, double: double, merge: merge, sep: sep)
317
342
  elsif q.include?(key)
318
- add quote_option(key, val, double: qq.include?(key), merge: merge, sep: sep)
343
+ add quote_option(key, val, double: double || qq.include?(key), merge: merge, sep: sep)
319
344
  elsif p.include?(key)
320
- if val.match?(/\A(["']).+\1\z/)
321
- add shell_option(key, val, escape: false, merge: merge, sep: sep)
345
+ if !double.nil?
346
+ add shell_option(key, val, double: double, merge: merge, sep: sep, escape: false)
322
347
  elsif path
323
348
  add quote_option(key, path + val, merge: merge, sep: sep)
324
349
  else
325
350
  push opt
326
351
  end
327
352
  elsif b.include?(key) || (bl.include?(key) && %w[true false].include?(val)) || numcheck.call(key, val)
328
- add basic_option(key, val, merge: merge, sep: sep)
353
+ add basic_option(key, val, double: double, merge: merge, sep: sep)
329
354
  elsif merge
330
- add basic_option(key, val, merge: true, sep: sep)
355
+ add basic_option(key, val, double: double, merge: true, sep: sep)
331
356
  else
332
357
  push opt
333
358
  end
@@ -251,7 +251,7 @@ module Squared
251
251
 
252
252
  def repo_run(cmd, exception: false)
253
253
  puts log_message(cmd, subject: main, hint: root) if verbose
254
- Common::System.shell(cmd, chdir: root, exception: exception)
254
+ Common::System.shell(cmd, chdir: root, exception: exception || env('REPO_FAIL', equals: %w[1 true]))
255
255
  end
256
256
 
257
257
  def repo_bin
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.17
4
+ version: 0.6.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  requirements: []
127
- rubygems_version: 4.0.15
127
+ rubygems_version: 4.0.21
128
128
  specification_version: 4
129
129
  summary: Rake task generator for managing multi-language workspaces.
130
130
  test_files: []