Arborist::

CLI

module
Extended With
Arborist::MethodUtilities
Arborist::CLI::Loggability
GLI::App
GLI::DSL

The command-line interface to Arborist.

Public Class Methods

anchor
add_registered_subcommands()

Add the commands from the registered subcommand modules.

# File lib/arborist/cli.rb, line 138
def self::add_registered_subcommands
        self.subcommand_modules ||= []
        self.subcommand_modules.each do |mod|
                merged_commands = mod.commands.merge( self.commands )
                self.commands.update( merged_commands )
                command_objs = self.commands_declaration_order | self.commands.values
                self.commands_declaration_order.replace( command_objs )
        end
end
anchor
commands_from( subdir )

Load commands from any files in the specified directory relative to LOAD_PATHs

# File lib/arborist/cli.rb, line 365
def self::commands_from( subdir )
        Gem.find_latest_files( File.join(subdir, '*.rb') ).each do |rbfile|
                self.log.debug "  loading %s..." % [ rbfile ]
                require( rbfile )
        end
end
anchor
load_config( global={} )

Load the config file using either arborist-base's config-loader if available, or fall back to DEFAULT_CONFIG_FILE

# File lib/arborist/cli.rb, line 212
def self::load_config( global={} )
        Arborist.load_config( global[:c] )

        # Set up the logging formatter
        Loggability.format_with( :color ) if $stdout.tty?
end
anchor
pastel()

Return the Pastel colorizer.

# File lib/arborist/cli.rb, line 151
def self::pastel
        @pastel ||= Pastel.new( enabled: $stdout.tty? && $COLOR )
end
anchor
prompt()

Return the TTY prompt used by the command to communicate with the user.

# File lib/arborist/cli.rb, line 158
def self::prompt
        @prompt ||= TTY::Prompt.new
end
anchor
register_subcommands( mod )

Add the specified +mod+ule containing subcommands to the 'arborist' command.

# File lib/arborist/cli.rb, line 129
def self::register_subcommands( mod )
        self.subcommand_modules ||= []
        self.subcommand_modules.push( mod )
        mod.extend( GLI::DSL, GLI::AppSupport, Loggability )
        mod.log_to( :arborist )
end
anchor
require_additional_libs( requires)

Load any additional Ruby libraries given with the -r global option.

# File lib/arborist/cli.rb, line 181
def self::require_additional_libs( requires)
        requires.each do |path|
                path = "arborist/#{path}" unless path.start_with?( 'arborist/' )
                require( path )
        end
end
anchor
reset_prompt()

Discard the existing HighLine prompt object if one existed. Mostly useful for testing.

# File lib/arborist/cli.rb, line 165
def self::reset_prompt
        @prompt = nil
end
anchor
run( * )

Overridden – Add registered subcommands immediately before running.

# File lib/arborist/cli.rb, line 122
def self::run( * )
        self.add_registered_subcommands
        super
end
anchor
set_logging_level( level=nil )

Set the global logging level if it's defined.

# File lib/arborist/cli.rb, line 171
def self::set_logging_level( level=nil )
        if level
                Loggability.level = level.to_sym
        else
                Loggability.level = :fatal
        end
end
anchor
setup_output( global )

Set up the output levels and globals based on the associated global options.

# File lib/arborist/cli.rb, line 221
def self::setup_output( global )

        # Turn on Ruby debugging and/or verbosity if specified
        if global[:n]
                $DRYRUN = true
                Loggability.level = :warn
        else
                $DRYRUN = false
        end


        if global[:verbose]
                $VERBOSE = true
                Loggability.level = :info
        end

        if global[:debug]
                $DEBUG = true
                Loggability.level = :debug
        end

        $COLOR = global[ :color ]
end
anchor
setup_pastel_aliases()

Setup pastel color aliases

# File lib/arborist/cli.rb, line 191
def self::setup_pastel_aliases
        self.pastel.alias_color( :headline, :bold, :white, :on_black )
        self.pastel.alias_color( :success, :bold, :green )
        self.pastel.alias_color( :error, :bold, :red )
        self.pastel.alias_color( :up, :green )
        self.pastel.alias_color( :down, :red )
        self.pastel.alias_color( :unknown, :dark, :yellow )
        self.pastel.alias_color( :disabled, :dark, :white )
        self.pastel.alias_color( :quieted, :dark, :green )
        self.pastel.alias_color( :acked, :yellow )
        self.pastel.alias_color( :warn, :bold, :magenta )
        self.pastel.alias_color( :highlight, :bold, :yellow )
        self.pastel.alias_color( :search_hit, :black, :on_white )
        self.pastel.alias_color( :prompt, :cyan )
        self.pastel.alias_color( :even_row, :bold )
        self.pastel.alias_color( :odd_row, :reset )
end

Public Instance Methods

anchor
subcommand_modules()

Registered subcommand modules

# File lib/arborist/cli.rb, line 118
singleton_attr_accessor :subcommand_modules