Sha256: f9b86e06688af7fdf02de1175a6ef65972326054ba0fd07a35a179020290bd68

Contents?: true

Size: 1.55 KB

Versions: 12

Compression:

Stored size: 1.55 KB

Contents

# -*- coding: UTF-8 -*-

require 'build-tool/commands'

module BuildTool; module Commands; module Features

    #
    # BuildCommand
    #
    class Enable < Standard

        name        'enable'
        description 'Enable the given features.'
        long_description [ 'Sets the features 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
                }

            super
        end

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

        def do_execute( args )

            for feat in args
                enable_feature( feat )
            end

            configuration.save()

            return 0
        end

        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

    end # class Activate

end; end; end # module BuildTool::Commands::Modules



Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
build-tool-0.6.9 lib/build-tool/commands/features/enable.rb
build-tool-0.6.8 lib/build-tool/commands/features/enable.rb
build-tool-0.6.7 lib/build-tool/commands/features/enable.rb
build-tool-0.6.6 lib/build-tool/commands/features/enable.rb
build-tool-0.6.5 lib/build-tool/commands/features/enable.rb
build-tool-0.6.4 lib/build-tool/commands/features/enable.rb
build-tool-0.6.3 lib/build-tool/commands/features/enable.rb
build-tool-0.6.2 lib/build-tool/commands/features/enable.rb
build-tool-0.6.1 lib/build-tool/commands/features/enable.rb
build-tool-0.6.0 lib/build-tool/commands/features/enable.rb
build-tool-0.6.0.rc2 lib/build-tool/commands/features/enable.rb
build-tool-0.6.0.rc1 lib/build-tool/commands/features/enable.rb