Class: BuildTool::Commands::Features::Enable

Inherits:
Standard
  • Object
show all
Defined in:
lib/build-tool/commands/features/enable.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/enable.rb', line 29

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

#do_execute(args) ⇒ Object



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

def do_execute( args )

    for feat in args
        enable_feature( feat )
    end

    configuration.save()

    return 0
end

#enable_feature(name) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/build-tool/commands/features/enable.rb', line 44

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

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

    if @default and feature.default_active? == true
        info( '%-35s: using default (enabled).' % feature.name )
        feature.active = nil
    else
        info( '%-35s: enabled explicitely.' % feature.name )
        feature.active = true
    end
end

#initialize_optionsObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/build-tool/commands/features/enable.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