Module: Boson::RunnerOptions
- Included in:
- BinRunner
- Defined in:
- lib/boson/runner_options.rb
Instance Method Summary collapse
- #abort_with(message) ⇒ Object
- #default_libraries ⇒ Object
- #execute_option_or_command(options, command, args) ⇒ Object
-
#init ⇒ Object
- :help
-
Gives a basic help of global options.
- #load_options ⇒ Object
- #print_usage ⇒ Object
- #update_index ⇒ Object
- #verbose ⇒ Object
Instance Method Details
#abort_with(message) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/boson/runner_options.rb', line 46 def abort_with() if verbose || [:backtrace] += "\nOriginal error: #{$!}\n #{$!.backtrace.join("\n ")}" end super() end |
#default_libraries ⇒ Object
30 31 32 33 |
# File 'lib/boson/runner_options.rb', line 30 def default_libraries libs = super @options[:unload] ? libs.select {|e| e !~ /#{@options[:unload]}/} : libs end |
#execute_option_or_command(options, command, args) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/boson/runner_options.rb', line 62 def execute_option_or_command(, command, args) if [:help] autoload_command command Boson.invoke(:usage, command, verbose: verbose) else super end end |
#init ⇒ Object
- :help
-
Gives a basic help of global options. When a command is given the help shifts to a command’s help.
- :verbose
-
Using this along with :help option shows more help. Also gives verbosity to other actions i.e. loading.
- :backtrace
-
Prints full backtrace on error. Default is false.
- :index
-
Updates index for given libraries allowing you to use them. This is useful if Boson’s autodetection of changed libraries isn’t picking up your changes. Since this option has a :bool_default attribute, arguments passed to this option need to be passed with ‘=’ i.e. ‘–index=my_lib’.
- :load
-
Explicitly loads a list of libraries separated by commas. Most useful when used with :console option. Can also be used to explicitly load libraries that aren’t being detected automatically.
- :pager_toggle
-
Toggles Hirb’s pager in case you’d like to pipe to another command.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/boson/runner_options.rb', line 14 def init super Boson.verbose = true if [:verbose] if @options.key?(:index) Index.update(:verbose=>true, :libraries=>@options[:index]) @index_updated = true elsif !@options[:help] && @command && Boson.can_invoke?(@command) Index.update(:verbose=>@options[:verbose]) @index_updated = true end Manager.load @options[:load], if @options[:load] View.toggle_pager if @options[:pager_toggle] end |
#load_options ⇒ Object
71 72 73 |
# File 'lib/boson/runner_options.rb', line 71 def super.update(verbose: @options[:verbose]) end |
#print_usage ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/boson/runner_options.rb', line 53 def print_usage super if @options[:verbose] Manager.load [Boson::Commands::Core] puts "\n\nDEFAULT COMMANDS" Boson.invoke :commands, :fields=>["name", "usage", "description"], :description=>false end end |
#update_index ⇒ Object
35 36 37 38 39 40 |
# File 'lib/boson/runner_options.rb', line 35 def update_index unless @index_updated super @index_updated = true end end |
#verbose ⇒ Object
42 43 44 |
# File 'lib/boson/runner_options.rb', line 42 def verbose @options[:verbose] end |