module GLI::AppSupport

Internals for make App work

Public Instance Methods

argument_handling_strategy() click to toggle source
# File lib/gli/app_support.rb, line 208
def argument_handling_strategy
  @argument_handling_strategy || :loose
end
around_blocks() click to toggle source
# File lib/gli/app_support.rb, line 161
def around_blocks
  @around_blocks || []
end
autocomplete() click to toggle source
# File lib/gli/app_support.rb, line 216
def autocomplete
  @autocomplete.nil? ? true : @autocomplete
end
context_description() click to toggle source
# File lib/gli/app_support.rb, line 9
def context_description
  "in global context"
end
exe_name() click to toggle source
# File lib/gli/app_support.rb, line 36
def exe_name
  File.basename($0)
end
get_default_command() click to toggle source

Get the default command for the entire app

# File lib/gli/app_support.rb, line 51
def get_default_command
  @default_command
end
help_sort_type() click to toggle source
# File lib/gli/app_support.rb, line 165
def help_sort_type
  @help_sort_type || :alpha
end
help_text_wrap_type() click to toggle source
# File lib/gli/app_support.rb, line 169
def help_text_wrap_type
  @help_text_wrap_type || :to_terminal
end
override_command_defaults(command_list,config) click to toggle source
# File lib/gli/app_support.rb, line 185
def override_command_defaults(command_list,config)
  command_list.each do |command_name,command|
    next if command_name == :initconfig || command.nil?
    command_config = (config['commands'] || {})[command_name] || {}

    if @subcommand_option_handling_strategy == :legacy
      override_default(command.topmost_ancestor.flags,command_config)
      override_default(command.topmost_ancestor.switches,command_config)
    else
      override_default(command.flags,command_config)
      override_default(command.switches,command_config)
    end

    override_command_defaults(command.commands,command_config)
  end
end
override_default(tokens,config) click to toggle source
# File lib/gli/app_support.rb, line 202
def override_default(tokens,config)
  tokens.each do |name,token|
    token.default_value=config[name] unless config[name].nil?
  end
end
override_defaults_based_on_config(config) click to toggle source

Sets the default values for flags based on the configuration

# File lib/gli/app_support.rb, line 178
def override_defaults_based_on_config(config)
  override_default(flags,config)
  override_default(switches,config)

  override_command_defaults(commands,config)
end
post_block() click to toggle source
# File lib/gli/app_support.rb, line 156
def post_block
  @post_block ||= Proc.new do
  end
end
pre_block() click to toggle source
# File lib/gli/app_support.rb, line 150
def pre_block
  @pre_block ||= Proc.new do
    true
  end
end
stderr() click to toggle source
# File lib/gli/app_support.rb, line 124
def stderr
  @stderr ||= STDERR
end
subcommand_option_handling_strategy() click to toggle source
# File lib/gli/app_support.rb, line 212
def subcommand_option_handling_strategy
  @subcommand_option_handling_strategy || :legacy
end
synopsis_format_type() click to toggle source
# File lib/gli/app_support.rb, line 173
def synopsis_format_type
  @synopsis_format_type || :full
end

Public Class Methods

included(klass) click to toggle source
# File lib/gli/app_support.rb, line 128
def self.included(klass)
  @stderr = $stderr
end