CliSpinnable
CliSpinnable, a module that enriches ruby command line with:
- rotating spinner
- check mark ✓
- fail mark ×
Dependencies
- Ruby >= 2.1
Installation
Add this line to your application's Gemfile:
gem 'cli_spinnable'And then execute:
$ bundle
Or install it yourself as:
$ gem install cli_spinnable
How to use
-
Mix-in CliSpinnable module into YourClass
class YourClass include CliSpinnable -
Call
with_spinnerinsideyour_methodproviding a blockdef your_method with_spinner do |cli| # ... end end -
Use
#printand#tickmethodswith_spinner do |cli| cli.print 'Downloading something' sleep 1 # some long operation cli.print '...downloaded 1MB' cli.tick cli.print 'Processing data' sleep 1 # other long operation cli.tick end -
If operation will fail (exception raised within the block), × will be printed
with_spinner do |cli| cli.print 'Trying to do something that can fail' 1 / 0 # raise Error cli.tick # you will not see the tick end
Demo
Development
After checking out the repo, run bin/setup to install dependencies. Then, run rspec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/maicher/cli_spinnable. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.
