Class: BuildTool::Commands::Shell
Instance Attribute Summary
Attributes inherited from Base
#cmd, #options, #parent
Instance Method Summary
collapse
Methods inherited from SubCommands
#add_command, #complete_arguments, #complete_command, #do_complete, #execute, #get_command, #help_commands, #initialize, #load_commands, #show_help
Methods inherited from Base
#<=>, #applicable?, #cleanup_after_vcs_access, #complete_arguments, #complete_readline, #configuration, #debug, #debug2, #do_complete, #do_execute, #each_option, #error, #execute, #fullname, #info, #initialize, #log?, #quiet, #setup_options, #show_help, #skip_command, #summarize, #teardown_command, #trace, #usage, #verbose, #warn
Methods included from HelpText
#cmdalias, #description, included, #long_description
Instance Method Details
#cli ⇒ Object
Also known as:
default_command
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
|
# File 'lib/build-tool/commands.rb', line 970
def cli
require 'readline'
Readline.completion_proc = method(:complete_readline)
while true
begin
line = Readline.readline('> ', true)
return 0 if line.nil?
next if Shellwords.shellwords( line ).length == 0
if line =~ /^\s*$/ or Readline::HISTORY.to_a[-2] == line
Readline::HISTORY.pop
end
execute Shellwords.shellwords( line )
rescue BuildTool::Error => e
error( e.message )
verbose( e.backtrace.join("\n") )
rescue StandardError => e
error( e.message )
error( e.backtrace.join("\n") )
rescue Interrupt => e
info( "Use CTRL-D for exit!" )
end
end
return 0
end
|
#initialize_options ⇒ Object
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
|
# File 'lib/build-tool/commands.rb', line 910
def initialize_options
options.banner = "Usage: #{name} [OPTIONS]... COMMAND [COMMAND OPTIONS]..."
options.separator ''
options.separator "Options"
options.on( "-v", "--verbose", "Enable verbose output" ) do
Logging.appenders['stdout'].level = [ Logging.appenders['stdout'].level - 1, 0 ].max()
end
options.on( nil, "--dry-run", "Enable dry run." ) do
$noop = true
end
options.on( "-V", "--version", "Print version information." ) do
show_version
end
options.on( "--ionice", "Set io io niceness to idle (3)." ) { |n|
pid = Process.pid()
system( "ionice -p #{pid} -c 3" )
cur = `ionice -p #{pid}`
info( 'Process priority (io niceness): %s' % cur )
}
options.on( "--nice N", "Set niceness to N." ) { |n|
if not /^[0-9]+$/.match( n )
raise OptionParser::ParseError.new( 'value "%s" is not a number' % n )
end
Process.setpriority( Process::PRIO_PROCESS, 0, n.to_i() )
cur = Process.getpriority( Process::PRIO_PROCESS, 0 )
if n.to_i() != cur
warn( 'Process priority (niceness): %d (%d was given)' % [ cur, n ] )
else
info( 'Process priority (niceness): %d' % [ cur ] )
end
}
options.on( "--debug-db", "Debug the database." ) do
Logging.logger['ActiveRecord'].level = :debug
end
super()
end
|
#name ⇒ Object
906
907
908
|
# File 'lib/build-tool/commands.rb', line 906
def name
return Pathname.new($0).basename.to_s
end
|
#setup_command ⇒ Object
960
961
962
963
|
# File 'lib/build-tool/commands.rb', line 960
def setup_command
load_commands( Application::instance.application_root.join( "lib/build-tool/commands" ), BuildTool::Commands )
end
|
#show_version ⇒ Object
965
966
967
968
|
# File 'lib/build-tool/commands.rb', line 965
def show_version
@skip_command = true
info( "#{name()}: Version #{BuildTool::VERSION}" )
end
|