class Cerebro::Command::Clean

Public Class Methods

new(argv) click to toggle source
Calls superclass method
# File lib/cerebro/command/clean.rb, line 11
def initialize(argv)
  @clean_specs = argv.arguments
  @repo = argv.shift_argument
  @clean_all = argv.flag?('all')
  super
end
options() click to toggle source
Calls superclass method
# File lib/cerebro/command/clean.rb, line 18
def self.options
  [
    ['--all', 'Clean all locally cloned repos used by Cerebro'],
  ].concat(super).reject { |(name, _)| name == '--no-all' }
end

Public Instance Methods

run() click to toggle source
# File lib/cerebro/command/clean.rb, line 35
def run
  if @clean_all
    FileUtils.rm_rf("#{Cerebro.storage_directory}/.")
    puts "Cleaned up all local clones created by Cerebro"
  else
    Dir.chdir(Cerebro.storage_directory) do
      FileUtils.rm_rf("#{@repo}-forks")
    end
    puts "Cleaned up all local clones of #{@repo} forks created by Cerebro"
  end
end
validate!() click to toggle source
Calls superclass method Cerebro::Command#validate!
# File lib/cerebro/command/clean.rb, line 24
      def validate!
        super

        if !@clean_all && @clean_specs.length != 1
          help = <<-HELP
Usage: cerebro clean <repo_name>
          HELP
          help! help
        end
      end