# -*- coding: UTF-8 -*- require 'build-tool/commands' module BuildTool; module Commands; module Modules # # BuildCommand # class Disable < ModuleBasedCommand name 'disable' description 'Disable the given modules.' long_description [ 'Sets the modules status.' ] def initialize_options options.banner = "Usage: #{self.fullname} [OPTIONS]... FEATURE..." options.separator( "" ) options.separator( "Options" ) @default = false options.on( "--default", "Set to use default state if possible." ) { |t| @default = true } @remove_build_directory = false options.on( "--rm-bld", "Remove the build directory." ) { @remove_build_directory = true } @remove_source_directory = false options.on( "--rm-src", "Remove the source directory." ) { @remove_source_directory = true } options.on( "--rm-both", "Remove the source and build directory." ) { @remove_source_directory = true @remove_build_directory = true } super # We want to allways match all modules here. @all = true end def applicable? BuildTool::Application.instance.has_recipe? end def do_execute( args ) super( args ) configuration.save() return 0 end def do_execute_module( mod ) if @default and mod.default_active? == false info( '%s: using default (disabled).' % mod.name ) mod.active = nil else info( '%s: disabled explicitely.' % mod.name ) mod.active = false end if mod.source_directory.exist? if @remove_source_directory remove_source_directory( mod, true ) else info( 'Source directory %s still exists.' % mod.source_directory ) verbose( 'module clean --rm-src to remove it' ) end elsif @remove_source_directory info( 'Source directory does not exist.' ) end if mod.build_directory.exist? if @remove_build_directory remove_build_directory( mod, true ) else info( 'Build directory %s still exists.' % mod.build_directory ) verbose( 'module clean --rm-bld to remove it' ) end elsif @remove_build_directory info( 'Build directory does not exist.' ) end end end # class Activate end; end; end # module BuildTool::Commands::Modules