Add better cursor display management

This commit is contained in:
Glenn Y. Rolland 2022-08-17 18:50:03 +02:00
parent 7f9db265b4
commit 84615d228e

View file

@ -10,7 +10,6 @@ require 'tty-spinner'
require 'colorize'
class ListRepos < Thor
desc 'list [SELECTOR]', 'List repositories'
method_option :root, type: :string, aliases: '-r'
@ -19,10 +18,15 @@ class ListRepos < Thor
super
end
def list(selector_str='')
trap 'SIGINT' do
system 'tput cnorm' # show cursor (fix)
exit! 130
end
basedir = options['root'] || '.'
projects = []
spinner = TTY::Spinner.new(
hide_cursor: true,
hide_cursor: true,
clear: true
)
@ -32,6 +36,7 @@ class ListRepos < Thor
## COLLECT
spinner.auto_spin
system 'tput civis' # hide cursor (fix)
Find.find(basedir) do |path|
next unless path =~ %r{.*/.git/config$}
@ -46,6 +51,8 @@ class ListRepos < Thor
}
end
spinner.stop
system 'tput cnorm' # show cursor (fix)
puts ''
## REDUCE
projects_selected = projects.select do |vals|