summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spandx/cli/commands/pull.rb28
-rw-r--r--spec/fixtures/pull.expected4
2 files changed, 21 insertions, 11 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
diff --git a/spec/fixtures/pull.expected b/spec/fixtures/pull.expected
index e7a15cc..d86bac9 100644
--- a/spec/fixtures/pull.expected
+++ b/spec/fixtures/pull.expected
@@ -1,5 +1 @@
-Updating https://github.com/spandx/cache.git...
-Updating https://github.com/spandx/rubygems-cache.git...
-Updating https://github.com/spdx/license-list-data.git...
-Rebuilding index...
OK