From 8fbf907eed52c36970c1d911d4acfeba76bb3aee Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 18 Nov 2020 16:40:47 -0700 Subject: feat: improve spinner formatting --- lib/spandx/cli/commands/pull.rb | 2 +- lib/spandx/cli/printers/table.rb | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/spandx/cli/commands/pull.rb b/lib/spandx/cli/commands/pull.rb index ebf4618..bcff1b0 100644 --- a/lib/spandx/cli/commands/pull.rb +++ b/lib/spandx/cli/commands/pull.rb @@ -37,7 +37,7 @@ module Spandx end def with_spinner(message, output:) - spinner = TTY::Spinner.new("[:spinner] #{message}", clear: false, output: output) + spinner = TTY::Spinner.new("[:spinner] #{message}", output: output) spinner.auto_spin yield spinner.success('(done)') diff --git a/lib/spandx/cli/printers/table.rb b/lib/spandx/cli/printers/table.rb index 931b739..e9672e8 100644 --- a/lib/spandx/cli/printers/table.rb +++ b/lib/spandx/cli/printers/table.rb @@ -6,8 +6,9 @@ module Spandx class Table < Printer HEADINGS = ['Name', 'Version', 'Licenses', 'Location'].freeze - def initialize - @spinner = TTY::Spinner.new(output: $stderr) + def initialize(output: $stderr) + @spinner = TTY::Spinner.new('[:spinner] Scanning...', output: output, clear: true, format: :dots) + @spinner.auto_spin end def match?(format) @@ -16,7 +17,6 @@ module Spandx def print_header(_io) @dependencies = SortedSet.new - @spinner.auto_spin end def print_line(dependency, _io) @@ -25,6 +25,7 @@ module Spandx def print_footer(io) @spinner.stop + @spinner.reset io.puts(to_table(@dependencies.map(&:to_a))) end -- cgit v1.2.3