squared 0.6.3 → 0.6.5

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.
@@ -154,14 +154,15 @@ module Squared
154
154
  task action, [:command] do |_, args|
155
155
  command = param_guard(action, 'command', args: args, key: :command)
156
156
  args = args.extras
157
- ls = case command
158
- when 'image', 'container', 'network'
159
- 'ls'
160
- when 'compose'
161
- 'ps'
162
- else
163
- raise_error ArgumentError, 'unrecognized command', hint: command
164
- end
157
+ cmd = docker_output(command, case command
158
+ when 'image', 'container', 'network'
159
+ 'ls'
160
+ when 'compose'
161
+ 'ps'
162
+ else
163
+ raise_error ArgumentError, 'unrecognized command', hint: command
164
+ end)
165
+ cmd << '-a' if has_value!(args, 'a', 'all') && command != 'network'
165
166
  data = VAL_DOCKER[:ls][command.to_sym]
166
167
  if has_value!(args, 's', 'standard')
167
168
  cols = data.first(data.index('CreatedAt'))
@@ -180,8 +181,6 @@ module Squared
180
181
  cols = choice_index('Select a column', data, multiple: true, force: true, attempts: 1)
181
182
  end
182
183
  end
183
- cmd = docker_output command, ls
184
- cmd << '-a' unless command == 'network' || !has_value!(args, 'a', 'all')
185
184
  cmd << quote_option('format', "table #{cols.map! { |val| "{{.#{val}}}" }.join("\t")}")
186
185
  run(cmd, banner: false, from: :ls)
187
186
  end
@@ -201,7 +200,7 @@ module Squared
201
200
 
202
201
  case flag
203
202
  when :build
204
- format_desc action, flag, 'opts*,target*,context?|:'
203
+ format_desc action, flag, 'opts*,target*,context|:'
205
204
  task flag do |_, args|
206
205
  args = args.to_a
207
206
  if args.first == ':'
@@ -222,7 +221,7 @@ module Squared
222
221
 
223
222
  case flag
224
223
  when :exec, :run
225
- format_desc action, flag, "service|:,command#{'?' unless flag == :exec}|::,args*,opts*"
224
+ format_desc action, flag, "service/:,command#{'?' unless flag == :exec}/::,args*,opts*"
226
225
  task flag, [:service] do |_, args|
227
226
  service = param_guard(action, flag, args: args, key: :service)
228
227
  compose!(flag, args.extras, service: service)
@@ -374,9 +373,7 @@ module Squared
374
373
  end
375
374
  append_context
376
375
  when :bake, :compose
377
- option(from == :bake ? 'target' : 'service', ignore: false) do |val|
378
- ret.merge(split_escape(val).map! { |s| shell_quote(s) })
379
- end
376
+ option(from == :bake ? 'target' : 'service', ignore: false) { |val| ret.merge(split_escape(val).quote!) }
380
377
  end
381
378
  ret
382
379
  end
@@ -494,7 +491,7 @@ module Squared
494
491
  end
495
492
  args << "#{k}=#{q + v + q}"
496
493
  elsif !silent?
497
- log_message(Logger::INFO, 'unrecognized option', subject: from, hint: k)
494
+ log_message('unrecognized option', subject: from, hint: k)
498
495
  end
499
496
  end
500
497
  raise_error TypeError, 'none specified', hint: flag unless type
@@ -714,7 +711,7 @@ module Squared
714
711
  when 2, 4
715
712
  return
716
713
  when 3
717
- return unless COMPOSEFILE.select { |val| basepath(val).exist? }.size > 1
714
+ return unless COMPOSEFILE.select { |val| basepath!(val) }.size > 1
718
715
  end
719
716
  end
720
717
  files = Array(@file).map { |val| quote_option('file', basepath(val)) }
@@ -841,7 +838,7 @@ module Squared
841
838
 
842
839
  def list_empty(subject: name, hint: nil, **kwargs)
843
840
  hint = "status: #{hint.join(', ')}" if hint.is_a?(Array)
844
- puts log_message(Logger::INFO, 'none detected', subject: subject, hint: hint, **kwargs)
841
+ puts log_message('none detected', subject: subject, hint: hint, **kwargs)
845
842
  end
846
843
 
847
844
  def confirm_command(*args, title: nil, target: nil, as: nil)
@@ -854,10 +851,8 @@ module Squared
854
851
  opt_style(theme[:caution], /\A(.+)\z/)
855
852
  ])
856
853
  printsucc
857
- a = t.last.capitalize
858
- b = sub_style target, theme[:subject]
859
- c = sub_style as, theme[:inline] if as
860
- confirm "#{a} #{b}#{" as #{c}" if c}?", 'N'
854
+ s = t.last.capitalize
855
+ confirm "#{s} #{sub_style(target, theme[:subject])}#{" as #{sub_style(as, theme[:inline])}" if as}?", 'N'
861
856
  end
862
857
 
863
858
  def choice_command(flag, *action)
@@ -880,8 +875,7 @@ module Squared
880
875
  lines = `#{docker_output(cmd)}`.lines
881
876
  header = lines.shift
882
877
  if lines.empty?
883
- puts log_message(Logger::INFO, 'none found', subject: name,
884
- hint: "docker #{cmd.split(' ', 3)[0...2].join(' ')}")
878
+ puts log_message('none found', subject: name, hint: "docker #{cmd.split(' ', 3)[0...2].join(' ')}")
885
879
  return
886
880
  end
887
881
  puts " # #{header}"
@@ -487,7 +487,7 @@ module Squared
487
487
  when 'stash'
488
488
  format_desc(action, flag, 'opts*', after: case flag
489
489
  when :push then 'pathspec*,:'
490
- when :branch then 'name,stash?|:'
490
+ when :branch then 'name,stash/:'
491
491
  when :clear, :list, :all then nil
492
492
  else 'stash?|:'
493
493
  end)
@@ -672,7 +672,7 @@ module Squared
672
672
  when 'branch'
673
673
  case flag
674
674
  when :create
675
- format_desc action, flag, 'name,ref?|:'
675
+ format_desc action, flag, 'name,ref/:'
676
676
  task flag, [:name, :ref] do |_, args|
677
677
  target = param_guard(action, flag, args: args, key: :name)
678
678
  ref = commithead args.ref
@@ -737,7 +737,7 @@ module Squared
737
737
  when 'switch'
738
738
  case flag
739
739
  when :create
740
- format_desc action, flag, '(^)name,ref?|:'
740
+ format_desc action, flag, '(^)name,ref/:'
741
741
  task flag, [:name, :commit] do |_, args|
742
742
  branch = param_guard(action, flag, args: args, key: :name)
743
743
  commit = commithead args.commit
@@ -751,7 +751,7 @@ module Squared
751
751
  switch(flag, commit: commit)
752
752
  end
753
753
  when :branch
754
- format_desc action, flag, 'name|:,opts*'
754
+ format_desc action, flag, 'name/:,opts*'
755
755
  task flag, [:name] do |_, args|
756
756
  args = if (branch = args.name)
757
757
  branch = nil if branch == ':'
@@ -765,7 +765,7 @@ module Squared
765
765
  when 'reset'
766
766
  case flag
767
767
  when :commit
768
- format_desc action, flag, 'ref|:,opts*'
768
+ format_desc action, flag, 'ref/:,opts*'
769
769
  task flag, [:commit] do |_, args|
770
770
  commit = commithead args.commit
771
771
  args = if commit && commit != ':'
@@ -787,7 +787,7 @@ module Squared
787
787
  reset(flag, flag == :index ? args.to_a : [])
788
788
  end
789
789
  when :mode
790
- format_desc action, flag, 'mode,ref?|:'
790
+ format_desc action, flag, 'mode,ref/:'
791
791
  task flag, [:mode, :ref] do |_, args|
792
792
  mode = param_guard(action, flag, args: args, key: :mode)
793
793
  ref = commithead args.ref
@@ -795,7 +795,7 @@ module Squared
795
795
  reset(flag, mode: mode, ref: ref)
796
796
  end
797
797
  when :patch
798
- format_desc action, flag, 'ref?|:,pathspec*'
798
+ format_desc action, flag, 'ref/:,pathspec*'
799
799
  task flag, [:ref] do |_, args|
800
800
  ref = commithead args.ref
801
801
  ref = choice_commit(reflog: false) unless ref && ref != ':'
@@ -921,7 +921,7 @@ module Squared
921
921
  restore(flag, args, commit: commit, files: files)
922
922
  end
923
923
  when :staged, :worktree
924
- format_desc action, flag, 'opts*,pathspec*,:?'
924
+ format_desc action, flag, 'opts*,pathspec*|:'
925
925
  task flag do |_, args|
926
926
  args = args.to_a
927
927
  if args.empty? || args.last == ':'
@@ -1066,7 +1066,7 @@ module Squared
1066
1066
  append_head branch
1067
1067
  else
1068
1068
  unless gitpath('REBASE_HEAD').exist?
1069
- puts log_message(Logger::INFO, name, 'no rebase in progress', hint: command) if stdout?
1069
+ puts log_message('no rebase in progress', subject: name, hint: command) if stdout?
1070
1070
  exit 1
1071
1071
  end
1072
1072
  return unless VAL_GIT[:rebase][:send].include?(command)
@@ -1143,7 +1143,7 @@ module Squared
1143
1143
  flag = :push
1144
1144
  end
1145
1145
  unless (file = gitpath('logs/refs/stash')).exist? || flag == :push
1146
- puts log_message(Logger::INFO, name, 'no stashes were found', hint: flag) if stdout?
1146
+ puts log_message('no stashes were found', subject: name, hint: flag) if stdout?
1147
1147
  exit 1
1148
1148
  end
1149
1149
  cmd, opts = git_session('stash', flag, opts: opts)
@@ -1237,14 +1237,14 @@ module Squared
1237
1237
  end
1238
1238
  out, banner, from = source(io: true)
1239
1239
  ret = write_lines(out, banner: banner, sub: sub)
1240
- list_result(ret, 'files', from: from, action: 'modified')
1240
+ list_result(ret, 'files', action: 'modified', from: from)
1241
1241
  end
1242
1242
 
1243
1243
  def revbuild(flag = nil, opts = [], sync: nil, **kwargs)
1244
1244
  kw = lambda do
1245
1245
  {
1246
- include: relativepath(Array(kwargs[:include]), all: true),
1247
- exclude: relativepath(Array(kwargs[:exclude]), all: true)
1246
+ include: relativepath(*Array(kwargs[:include]), all: true),
1247
+ exclude: relativepath(*Array(kwargs[:exclude]), all: true)
1248
1248
  }
1249
1249
  end
1250
1250
  unless workspace.closed
@@ -1277,7 +1277,7 @@ module Squared
1277
1277
  if cur['files'].size == files.size && cur['files'].find { |key, val| files[key] != val }.nil?
1278
1278
  workspace.rev_timeutc(name, 'build') unless (since = workspace.rev_timesince(name, 'build'))
1279
1279
  if stdout?
1280
- puts log_message(Logger::INFO, name, 'no changes', subject: 'revbuild', hint: ("#{since} ago" if since))
1280
+ puts log_message(['revbuild', 'no changes'], subject: name, hint: ("#{since} ago" if since))
1281
1281
  end
1282
1282
  return
1283
1283
  end
@@ -1287,7 +1287,7 @@ module Squared
1287
1287
  rescue StandardError => e
1288
1288
  print_error(e, pass: true)
1289
1289
  else
1290
- print_status(name, subject: 'revbuild', start: start, from: :completed)
1290
+ print_status('revbuild', subject: name, start: start, from: :completed)
1291
1291
  workspace.rev_write(name, { 'revision' => sha, 'files' => status_digest(*args, **kwargs) },
1292
1292
  sync: sync, utc: 'build')
1293
1293
  end
@@ -1380,15 +1380,11 @@ module Squared
1380
1380
  out, banner, from = source(io: true)
1381
1381
  print_item banner
1382
1382
  ret = write_lines(out, grep: op.extras)
1383
- list_result(ret, 'tags', from: from, grep: op.extras)
1383
+ list_result(ret, 'tags', grep: op.extras, from: from)
1384
1384
  return
1385
1385
  end
1386
1386
  remote ||= option('remote')
1387
- source.tap do |ret|
1388
- next unless ret && remote
1389
-
1390
- git_spawn('push', ('-d' if flag == :delete), remote, *refs.map! { |val| shell_quote(val) })
1391
- end
1387
+ source.tap { |ret| git_spawn('push', ('-d' if flag == :delete), remote, *refs.quote!) if ret && remote }
1392
1388
  end
1393
1389
 
1394
1390
  def log!(flag, opts = [], range: [], index: [], grep: [])
@@ -1545,7 +1541,7 @@ module Squared
1545
1541
  if banner?
1546
1542
  puts 'Nothing to commit'
1547
1543
  elsif stdout?
1548
- puts log_message(Logger::INFO, name, 'nothing to commit', hint: flag)
1544
+ puts log_message('nothing to commit', subject: name, hint: flag)
1549
1545
  end
1550
1546
  exit 1
1551
1547
  end
@@ -1567,7 +1563,7 @@ module Squared
1567
1563
  end
1568
1564
  else
1569
1565
  unless gitpath('MERGE_HEAD').exist?
1570
- puts log_message(Logger::INFO, name, 'no merge in progress', hint: command) if stdout?
1566
+ puts log_message('no merge in progress', subject: name, hint: command) if stdout?
1571
1567
  exit 1
1572
1568
  end
1573
1569
  return unless VAL_GIT[:merge][:send].include?(command)
@@ -1607,9 +1603,7 @@ module Squared
1607
1603
  cmd << shell_quote(target) if target
1608
1604
  end
1609
1605
  when :delete
1610
- remote&.each do |val|
1611
- source git_output('push --delete', *val.split('/', 2).map! { |s| shell_quote(s) })
1612
- end
1606
+ remote&.each { |val| source git_output('push --delete', *val.split('/', 2).quote!) }
1613
1607
  force, list = refs.partition { |val| val.start_with?(/[~^]/) }
1614
1608
  force.each do |val|
1615
1609
  r = '-r' if val.delete!('~')
@@ -1624,7 +1618,7 @@ module Squared
1624
1618
  s = +"-#{flag.to_s[0]}"
1625
1619
  s.upcase! if option('f', 'force')
1626
1620
  cmd << s
1627
- refs.compact.each { |val| cmd << shell_quote(val) }
1621
+ cmd.merge(refs.compact.quote!)
1628
1622
  stdout = true
1629
1623
  when :current
1630
1624
  cmd << '--show-current'
@@ -1784,7 +1778,7 @@ module Squared
1784
1778
  out, banner, from = source(io: true)
1785
1779
  print_item banner
1786
1780
  ret = write_lines(out, grep: op.extras, prefix: "refs/#{flag}/")
1787
- list_result(ret, flag.to_s, from: from, grep: op.extras)
1781
+ list_result(ret, flag.to_s, grep: op.extras, from: from)
1788
1782
  end
1789
1783
 
1790
1784
  def ls_files(flag, opts = [])
@@ -1794,7 +1788,7 @@ module Squared
1794
1788
  out, banner, from = source(io: true)
1795
1789
  print_item banner
1796
1790
  ret = write_lines(out, grep: op.extras)
1797
- list_result(ret, 'files', from: from, grep: op.extras)
1791
+ list_result(ret, 'files', grep: op.extras, from: from)
1798
1792
  end
1799
1793
 
1800
1794
  def git(flag, opts = [])
@@ -1976,7 +1970,7 @@ module Squared
1976
1970
  ret
1977
1971
  end
1978
1972
 
1979
- def list_result(size, type, grep: [], action: 'found', from: nil)
1973
+ def list_result(size, type, action: 'found', grep: [], from: nil)
1980
1974
  if size == 0
1981
1975
  puts empty_status("No #{type} were #{action}", 'grep', grep.join(', '))
1982
1976
  elsif stdout?
@@ -2198,7 +2192,7 @@ module Squared
2198
2192
  raise_error(ArgumentError, "missing #{origin ? 'branch' : 'remote'} name", hint: origin)
2199
2193
  end
2200
2194
  branch = "#{branch}:#{origin[i.succ..-1]}" unless origin.end_with?("/#{branch}")
2201
- [origin[0..i.pred], branch].tap { |ret| ret.map! { |val| shell_quote(val) } if quote }
2195
+ [origin[0..i.pred], branch].tap { |ret| ret.quote! if quote }
2202
2196
  end
2203
2197
 
2204
2198
  def commithash(val)
@@ -159,7 +159,7 @@ module Squared
159
159
  end
160
160
  @dependname = 'package.json'
161
161
  dependfile_set [@dependname]
162
- @tsfile = basepath(ts).yield_self { |file| file if file.exist? }
162
+ @tsfile = basepath! ts
163
163
  @pm = { __: init }
164
164
  end
165
165
 
@@ -280,7 +280,7 @@ module Squared
280
280
  flags.each do |flag|
281
281
  case action
282
282
  when 'outdated'
283
- format_desc action, flag, %w[u/pdate s/elect i/nteractive d/ry-run diff]
283
+ format_desc action, flag, "#{shortname('i', 's', 'u', 'd')},diff"
284
284
  task flag do |_, args|
285
285
  outdated flag, args.to_a
286
286
  end
@@ -331,11 +331,15 @@ module Squared
331
331
  format_desc(action, flag, 'opts*', "#{flag == :project ? 'before' : 'after'}": 'config?')
332
332
  task flag do |_, args|
333
333
  args = args.to_a
334
- tsc(*args, banner: true, "#{flag}": if flag == :build
335
- true
336
- else
337
- exist?(args.first) ? args.shift : @tsfile
338
- end, watch: has_value!(args, 'w', 'watch'))
334
+ if flag == :project
335
+ project = if exist?(args.first)
336
+ args.shift
337
+ else
338
+ @tsfile
339
+ end
340
+ end
341
+ watch = has_value!(args, 'w', 'watch')
342
+ tsc(*args, banner: true, project: project, build: flag == :build, watch: !watch.nil?)
339
343
  end
340
344
  end
341
345
  end
@@ -499,7 +503,7 @@ module Squared
499
503
  add = flag == :add
500
504
  if add
501
505
  remove, packages = packages.partition { |val| val.delete_prefix!('-') }
502
- remove.map! { |pkg| shell_quote(pkg) }
506
+ remove.quote!
503
507
  end
504
508
  save, exact, omit = save if save.is_a?(Array)
505
509
  ws = env('NODE_WORKSPACES', equals: '0')
@@ -598,7 +602,7 @@ module Squared
598
602
  if add
599
603
  return if packages.empty?
600
604
 
601
- cmd.merge(packages.map { |pkg| shell_quote(pkg) })
605
+ cmd.merge(packages.quote!)
602
606
  end
603
607
  run(from: flag || :depend, sync: sync)
604
608
  end
@@ -626,13 +630,20 @@ module Squared
626
630
  end
627
631
  found = []
628
632
  avail = []
629
- rev = flag || (prod? ? :patch : :minor)
633
+ flag ||= case (up = option('u', 'update'))
634
+ when 'major', 'minor'
635
+ up.to_sym
636
+ else
637
+ prod? ? :patch : :minor
638
+ end
630
639
  if sync && !stdin?
631
- if has_value?(opts, 's', 'select') && !dryrun
632
- items = []
633
- elsif has_value?(opts, 'i', 'interactive')
634
- ia = true
635
- end
640
+ items = if has_value?(opts, 's', 'select')
641
+ se = true
642
+ []
643
+ elsif has_value?(opts, 'i', 'interactive')
644
+ ia = true
645
+ []
646
+ end
636
647
  end
637
648
  unless data.empty?
638
649
  JSON.parse(data).each_pair do |key, val|
@@ -643,7 +654,7 @@ module Squared
643
654
  ch = file[0]
644
655
  if ch.match?(/[~^]/)
645
656
  file = file[1..-1]
646
- elsif ia && rev == :major
657
+ elsif ia && flag == :major
647
658
  major = true
648
659
  else
649
660
  avail << [key, file, latest, true]
@@ -652,7 +663,7 @@ module Squared
652
663
  current = val['current'] || file
653
664
  want = val['wanted']
654
665
  unless latest[SEM_VER, 6]
655
- case rev
666
+ case flag
656
667
  when :major
657
668
  want = latest
658
669
  when :minor
@@ -671,7 +682,7 @@ module Squared
671
682
  b = f[2]
672
683
  c = w[0]
673
684
  d = w[2]
674
- upgrade = case rev
685
+ upgrade = case flag
675
686
  when :major
676
687
  a == '0' ? c == '0' || c == '1' : true
677
688
  when :minor
@@ -713,6 +724,7 @@ module Squared
713
724
  if !found.empty?
714
725
  col1 = width.call(found, 0) + 4
715
726
  col2 = width.call(found, 1) + 4
727
+ col3 = pad.call(found.size, found).size + 2 + col1 + col2 + width.call(found, 2)
716
728
  packages = []
717
729
  pat = ->(a) { /("#{Regexp.escape(a[0])}"\s*:\s*)"([~^])#{'?' if a[4]}#{Regexp.escape(a[1])}"/ }
718
730
  edit = lambda do |a, pkg, mod|
@@ -720,60 +732,57 @@ module Squared
720
732
  modified += 1
721
733
  "#{pkg}\"#{mod || (a[3] == 1 && a[4] ? '^' : '')}#{a[2]}\""
722
734
  end
723
- kwargs = { col1: col1, col2: col2, col3: width.call(found, 2), timeout: 0 }
724
735
  found.each_with_index do |item, i|
725
736
  a, b, c, d, e = item
726
- f = ia && (rev != :major || e || semmajor?(item[5], item[6]))
727
- col0 = "#{pad.call(i, found)}. "
728
- if f && !confirm_outdated(a, c, (d / 2.0).ceil, b, lock: e, col0: col0, **kwargs)
729
- cur = -1
730
- else
731
- cur = modified
732
- doc.send(items ? :sub : :sub!, pat.call(item)) do |capture|
733
- if $2 == '~' && rev != :patch
734
- cur = -1
735
- pending += 1
736
- capture
737
- else
738
- edit.call(item, $1, $2)
739
- end
737
+ cur = modified
738
+ doc.send(items ? :sub : :sub!, pat.call(item)) do |capture|
739
+ if $2 == '~' && flag != :patch
740
+ cur = -1
741
+ pending += 1
742
+ capture
743
+ else
744
+ edit.call(item, $1, $2)
740
745
  end
741
746
  end
742
- if f
743
- a = ' ' * col1
744
- b = ' ' * col2
745
- else
746
- a = a.ljust(col1)
747
- b = b.ljust(col2)
748
- sub_style! b, theme[:current] if theme[:current] && !stdin?
747
+ a = a.ljust(col1)
748
+ b = b.ljust(col2)
749
+ sub_style! b, theme[:current] if theme[:current] && !stdin?
750
+ if cur == -1
751
+ c = 'SKIP'
752
+ elsif modified == cur
753
+ c = 'FAIL'
754
+ elsif !stdin?
755
+ if d == 1
756
+ sub_style! a, theme[:major]
757
+ sub_style! c, :bold, color(:green)
758
+ else
759
+ sub_style!(c, **opt_style(color(d == 3 ? :green : :yellow), SEM_VER, d))
760
+ end
761
+ g = item
749
762
  end
750
- c = if cur == -1
751
- 'SKIP'
752
- elsif modified == cur
753
- 'FAIL'
754
- elsif stdin?
755
- c
756
- else
757
- g = item
758
- if d == 1
759
- sub_style! a, theme[:major]
760
- sub_style c, :bold, color(:green)
761
- else
762
- sub_style(c, **opt_style(color(d == 3 ? :green : :yellow), SEM_VER, d))
763
- end
764
- end
765
- s = a + b + c
766
- if !items
767
- puts "#{f ? ' ' * col0.size : col0}#{s}"
768
- elsif g
763
+ s = "#{pad.call(i, found)}. #{a}#{b}#{c}"
764
+ if se
769
765
  items << [s, g]
766
+ next
767
+ elsif ia && g
768
+ items << [g]
769
+ if flag != :major || e || semmajor?(item[5], item[6])
770
+ items.pop unless confirm_semver(s.ljust(col3 + s.size - s.stripstyle.size), (d / 2.0).ceil)
771
+ next
772
+ end
770
773
  end
774
+ puts s
771
775
  end
772
776
  pending = avail.reduce(pending) { |a, b| a + (b[3] ? 0 : 1) }
773
- if dryrun || (modified == 0 && (pending > 0 || (items && pending == 0)))
777
+ if (dryrun && Array(items).empty?) || (modified == 0 && (pending > 0 || (items && pending == 0)))
774
778
  n = if items
775
- puts(items.empty? ? 'No updates were found' : items.map(&:first))
776
- items.size
779
+ if items.empty?
780
+ puts 'No updates were selected'
781
+ 0
782
+ else
783
+ puts items.map(&:first) if se
784
+ items.size
785
+ end
777
786
  else
778
787
  found.size
779
788
  end
@@ -781,24 +790,32 @@ module Squared
781
790
  elsif modified > 0
782
791
  if items
783
792
  packages.clear
784
- choice('Select a package', items.map(&:first), multiple: true, force: false, index: true, border: true)
785
- .each do |n|
786
- item = items[n.pred].last
787
- doc.sub!(pat.call(item)) { edit.call(item, $1, $2) }
788
- end
793
+ if ia
794
+ (1..items.size)
795
+ else
796
+ choice('Select a package', items.map(&:first), multiple: true, force: false, index: true,
797
+ border: true)
798
+ end.each do |n|
799
+ item = items[n.pred].last
800
+ doc.sub!(pat.call(item)) { edit.call(item, $1, $2) }
801
+ end
789
802
  end
790
803
  unless packages.empty?
791
- File.write(dependfile, doc)
792
- if sync && (opts.include?('diff') || option('diff'))
793
- run(git_output('diff', shell_quote(dependfile)), banner: false)
794
- end
795
- if has_value?(opts, 'u', 'update') || option('update')
796
- package(:update, packages: packages, from: :'outdated:update')
797
- else
798
- modified = -1
804
+ modified = -1
805
+ if dryrun
799
806
  footer.call(0, found.size)
807
+ else
808
+ File.write(dependfile, doc)
809
+ if sync && (opts.include?('diff') || option('diff'))
810
+ run(git_output('diff', shell_quote(dependfile)), banner: false)
811
+ end
812
+ if has_value?(opts, 'u', 'update') || up
813
+ package(:update, packages: packages, from: :'outdated:update')
814
+ else
815
+ footer.call(0, found.size)
816
+ end
817
+ commit(:add, [dependname], pass: true)
800
818
  end
801
- commit(:add, [dependname], pass: true)
802
819
  end
803
820
  end
804
821
  elsif !avail.empty?
@@ -1131,7 +1148,7 @@ module Squared
1131
1148
  end
1132
1149
 
1133
1150
  def outdated?
1134
- dependfile.exist?
1151
+ dependfile.exist? && !task_pass?('outdated')
1135
1152
  end
1136
1153
 
1137
1154
  def update?