Class: BuildTool::Commands::Modules::MyShell

Inherits:
BuildTool::Commands::ModuleBasedCommand show all
Includes:
MJ::Tools::SubProcess
Defined in:
lib/build-tool/commands/modules/shell.rb

Overview

BuildCommand

Instance Attribute Summary

Attributes inherited from Base

#cmd, #options, #parent

Instance Method Summary collapse

Methods inherited from BuildTool::Commands::ModuleBasedCommand

#clean, #clone, #configure, #fetch, #initialize, #install, #is_module_ready?, #make, #prepare_module, #rebase, #reconfigure, #remove_build_directory, #remove_source_directory, #summarize

Methods inherited from Standard

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

Methods inherited from Base

#<=>, #applicable?, #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::ModuleBasedCommand

Instance Method Details

#do_execute(args) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/build-tool/commands/modules/shell.rb', line 55

def do_execute( args )
    if @batch
        super( args )
    else
         # Check the number of commandline args
         if args.length != 1
             return usage( "Wrong number of arguments" )
         end

         # Translate argument into modules
         mod = complete_modules( args[0] )
         if mod.length != 1
             return usage( "This command only works on one module" )
         end

         return do_execute_module( mod[0] )
    end
end

#do_execute_module(mod) ⇒ Object



74
75
76
77
78
79
80
81
82
# File 'lib/build-tool/commands/modules/shell.rb', line 74

def do_execute_module( mod )
    verbose "> #{@command}"
    rc = mod.shell( @command, { detach: @detach, wd: mod.build_directory } )
    verbose "> #{rc}"              if not @detach
    verbose "> send to background" if @detach

    return rc.exitstatus if not @detach
    return 0
end

#initialize_optionsObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/build-tool/commands/modules/shell.rb', line 32

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
        }

    @batch = false
    options.on( "--batch", "Execute the command for many modules." ) {
        @batch = true
        }
    super

end