diff options
| author | mo khan <mo.khan@gmail.com> | 2020-11-18 15:59:32 -0700 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-11-18 15:59:32 -0700 |
| commit | 9a0f1bc1c0637bc07fbfc72f7edc4f7c0d23fee2 (patch) | |
| tree | d9a1d8bf89a3d6f4d4018e2da161bcd6f16cf939 /lib | |
| parent | b2f8c2d1408b8c27bb51714674c59257a8679102 (diff) | |
feat: display spinner while pulling the latest cache
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/spandx/cli/commands/pull.rb | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/lib/spandx/cli/commands/pull.rb b/lib/spandx/cli/commands/pull.rb index b866d43..1332492 100644 --- a/lib/spandx/cli/commands/pull.rb +++ b/lib/spandx/cli/commands/pull.rb @@ -10,17 +10,31 @@ module Spandx def execute(output: $stdout) Spandx.git.each_value do |db| - output.puts "Updating #{db.url}..." - db.update! + with_spinner("Updating #{db.url}...", output: output) do + db.update! + end end - output.puts "Rebuilding index..." - Spandx::Core::Dependency::PACKAGE_MANAGERS.values.uniq.each do |type| - Spandx::Core::Cache - .new(type, root: Spandx.git[:cache].root.join('.index')) - .rebuild_index + + with_spinner('Rebuilding index...', output: output) do + Spandx::Core::Dependency::PACKAGE_MANAGERS.values.uniq.each do |type| + Spandx::Core::Cache + .new(type, root: Spandx.git[:cache].root.join('.index')) + .rebuild_index + end end output.puts 'OK' end + + private + + def with_spinner(message, output:) + spinner = TTY::Spinner.new("[:spinner] #{message}", clear: false, output: output) + spinner.auto_spin + yield + spinner.success('(done)') + ensure + spinner.stop + end end end end |
