Class: BuildTool::Commands::Shell
- Inherits:
-
SubCommands
- Object
- Base
- SubCommands
- BuildTool::Commands::Shell
- Defined in:
- lib/build-tool/commands.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #cli ⇒ Object (also: #default_command)
- #initialize_options ⇒ Object
- #name ⇒ Object
- #setup_command ⇒ Object
- #show_version ⇒ Object
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
Constructor Details
This class inherits a constructor from BuildTool::Commands::SubCommands
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? # Ignore whitespace lines next if Shellwords.shellwords( line ).length == 0 # Remove duplicate or empty lines from history if line =~ /^\s*$/ or Readline::HISTORY.to_a[-2] == line Readline::HISTORY.pop end # Split the line like bash would do it execute Shellwords.shellwords( line ) rescue BuildTool::Error => e error( e. ) verbose( e.backtrace.join("\n") ) rescue StandardError => e error( e. ) 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 . = "Usage: #{name} [OPTIONS]... COMMAND [COMMAND OPTIONS]..." .separator '' .separator "Options" .on( "-v", "--verbose", "Enable verbose output" ) do Logging.appenders['stdout'].level = [ Logging.appenders['stdout'].level - 1, 0 ].max() end .on( nil, "--dry-run", "Enable dry run." ) do $noop = true end .on( "-V", "--version", "Print version information." ) do show_version end .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 ) } .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 # Set the priority Process.setpriority( Process::PRIO_PROCESS, 0, n.to_i() ) # Check if it worked. 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 } .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 # And the commands require all that database related stuff. load_commands( Application::instance.application_root.join( "lib/build-tool/commands" ), BuildTool::Commands ) end |