Sha256: 6da2c89a71de7487cf3dfd37d37474de1a014a6c5efcad2e5f9a13b7b8dfa3a2

Contents?: true

Size: 1.76 KB

Versions: 8

Compression:

Stored size: 1.76 KB

Contents

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

require 'build-tool/commands'

module BuildTool; module Commands; module Environments

    #
    # BuildCommand
    #
    class Set < Standard

        name        "set"
        description "Open a shell with the environment set."
        long_description [
            "Opens a new shell with the given environment and and executes COMMAND.",
            "It then waits for COMMAND to finish and returns its exit code. The",
            "default command is $SHELL." ]


        def do_execute( args )
            case args.length
            when 0
                return usage( "Not enough arguments." )
            when 1
                # OK
            else
                return usage( "To many arguments." )
            end

            # Get the environment.
            env = configuration.environment(args[0])

            verbose "> #{@command}"
            rc = env.shell( @command, { detach: @detach } )
            verbose "> #{rc}"              if not @detach
            verbose "> send to background" if @detach

            return rc.exitstatus if not @detach
            return 0
        end

        def initialize_options
            options.banner = "Usage: #{self.fullname} [OPTIONS]... MODULE"
            options.separator( "" )
            options.separator( "Options" )

            @command = ENV['SHELL']
            options.on( "-c", "--command COMMAND", "Execute command COMMAND (#{@command}]" ) { |c|
                @command = "#{ENV['SHELL']} -c '#{c}'"
                }

            @detach = nil
            options.on( "-d", "--detach", "Detach the process and return immediately." ) {
                @detach = true
                }
            super
        end

    end # class

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



Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
build-tool-0.6.9 lib/build-tool/commands/environments/set.rb
build-tool-0.6.8 lib/build-tool/commands/environments/set.rb
build-tool-0.6.7 lib/build-tool/commands/environments/set.rb
build-tool-0.6.6 lib/build-tool/commands/environments/set.rb
build-tool-0.6.5 lib/build-tool/commands/environments/set.rb
build-tool-0.6.4 lib/build-tool/commands/environments/set.rb
build-tool-0.6.3 lib/build-tool/commands/environments/set.rb
build-tool-0.6.2 lib/build-tool/commands/environments/set.rb