Class: BuildTool::Commands::Features::Disable

Inherits:
Standard
  • Object
show all
Defined in:
lib/build-tool/commands/features/disable.rb

Overview

BuildCommand

Instance Attribute Summary

Attributes inherited from Base

#cmd, #options, #parent

Instance Method Summary collapse

Methods inherited from Standard

#complete_module, #complete_modules, #initialize, #log_directory, #while_logging_to

Methods inherited from Base

#<=>, #cleanup_after_vcs_access, #complete_arguments, #complete_readline, #configuration, #debug, #debug2, #do_complete, #each_option, #error, #execute, #fullname, #info, #initialize, #log?, #quiet, #setup_command, #setup_options, #show_help, #skip_command, #summarize, #teardown_command, #trace, #usage, #verbose, #warn

Methods included from HelpText

#cmdalias, #description, included, #long_description, #name

Constructor Details

This class inherits a constructor from BuildTool::Commands::Standard

Instance Method Details

#applicable?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/build-tool/commands/features/disable.rb', line 29

def applicable?
    BuildTool::Application.instance.has_recipe?
end

#disable_feature(name) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/build-tool/commands/features/disable.rb', line 48

def disable_feature( name )
    feature = configuration.features[name]

    if feature.nil?
        error( "Unknown feature '%s'" % name )
        return -1
    end

    if @default and feature.default_active? == false
        info( '%s: using default (disabled).' % feature.name )
        feature.active = nil
    else
        info( '%s: disabled explicitely.' % feature.name )
        feature.active = false
    end
end

#do_execute(args) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/build-tool/commands/features/disable.rb', line 33

def do_execute( args )
    if args.length > 1
        # *TODO* print better message
        return usage "To many arguments."
    end

    for feat in args
        disable_feature( feat )
    end

    configuration.save()

    return 0
end

#initialize_optionsObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/build-tool/commands/features/disable.rb', line 16

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
        }

    super
end