Sha256: ebc598a2551e2693bfaf605ccdc0f82b48b7e4333a7cea7aa90aa50b550dc741

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require "claide"
require "info"
require "console"
require "fileutils"

module VsClean
  class Clean < CLAide::Command
    self.command = "vsclean"
    self.version = VsClean::VERSION
    self.description = VsClean::DESCRIPTION
    
    def initialize(argv)
      super
    end
    
    def run
      # Delete bin and obj directories
      paths = Dir.glob("**/{bin,obj}").select { |f| File.directory?(f) }
      
      # Delete .suo files (can cause Intellisense errors, among other things)
      paths.push(*Dir.glob("**/.vs/**/.suo"))
      
      if paths.none?
        Console.log_step("All is well with the world... nothing to clean!")
        return
      end
        
      Console.log_step("Cleaning...") 
      
      paths.each { |d| delete(d) }
      
      Console.log_step("Done!")
    end
    
    def delete(path)
      FileUtils.rm_r(path)
      Console.log_substep("Deleted ./#{path}")
    rescue StandardError => e
      Console.log_error("Could not delete './#{path}': #{e.message}")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vsclean-1.0.4 lib/clean.rb