Class: Cerebro::Command::Clean
- Inherits:
-
Cerebro::Command
- Object
- CLAide::Command
- Cerebro::Command
- Cerebro::Command::Clean
- Defined in:
- lib/cerebro/command/clean.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Clean
constructor
A new instance of Clean.
- #run ⇒ Object
- #validate! ⇒ Object
Methods inherited from Cerebro::Command
Constructor Details
#initialize(argv) ⇒ Clean
Returns a new instance of Clean.
11 12 13 14 15 16 |
# 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 |
Class Method Details
.options ⇒ Object
18 19 20 21 22 |
# File 'lib/cerebro/command/clean.rb', line 18 def self. [ ['--all', 'Clean all locally cloned repos used by Cerebro'], ].concat(super).reject { |(name, _)| name == '--no-all' } end |
Instance Method Details
#run ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# 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! ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# 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 |