Sha256: e57828bfe26a7e8bb1a99c03398ee4c6e1be997e286d0d389e21fa162df229ec

Contents?: true

Size: 1.69 KB

Versions: 11

Compression:

Stored size: 1.69 KB

Contents

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

require 'build-tool/commands'

module BuildTool; module Commands; module Features

    #
    # BuildCommand
    #
    class Disable < Standard

        name        'disable'
        description 'Disable 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 )
            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

        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

    end # class Activate

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



Version data entries

11 entries across 11 versions & 1 rubygems

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