kigster/warp-dir

View on GitHub
lib/warp/dir/command/clean.rb

Summary

Maintainability
A
0 mins
Test Coverage
F
46%
require 'warp/dir/command'
require 'warp/dir/formatter'

class Warp::Dir::Command::Clean < Warp::Dir::Command
  description %q(Removes any no-longer existing warp points)
  aliases :x

  def run(*)
    removed = store.clean!
    s = self.store
    if removed.empty?
      on :success do
        message "All entries are valid in your file #{s.config.warprc.blue} are #{'valid.'.green}"
      end
    else
      on :success do
        message "The following no-longer existing points have been removed:\n\n".bold +
                  ::Warp::Dir::Formatter::StoreFormatter.new(removed).format.bold.red
      end
    end
  end
end