Module: GemMirror::CLI

Defined in:
lib/gem_mirror/cli.rb

Overview

Namespace for classes and modules that handle the command line interface

Constant Summary collapse

SLOP_OPTIONS =

Hash containing the default Slop options.

Returns:

  • (Hash)
{
  strict: true,
  banner: "Usage: gem_mirror [COMMAND] [OPTIONS]"
}.freeze

Class Method Summary collapse

Class Method Details

.default_optionsSlop

Returns:

  • (Slop)


43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/gem_mirror/cli.rb', line 43

def self.default_options
  Slop.new(SLOP_OPTIONS.dup) do
    separator "\nOptions:\n"

    on :h, :help, "Shows this help message" do
      puts self
      exit
    end

    on :v, :version, "Shows the current version" do
      puts CLI.version_information
    end
  end
end

.load_configuration(config_file) ⇒ GemMirror::Configuration

Loads the specified configuration file or displays an error if it doesn’t exist.

Parameters:

  • config_file (String)

Returns:



31
32
33
34
35
36
37
38
# File 'lib/gem_mirror/cli.rb', line 31

def self.load_configuration(config_file)
  config_file ||= Configuration.default_configuration_file
  config_file   = File.expand_path(config_file, Dir.pwd)

  abort "The configuration file #{config_file} does not exist" unless File.file?(config_file)

  require(config_file)
end

.optionsSlop

Returns:

  • (Slop)


20
21
22
# File 'lib/gem_mirror/cli.rb', line 20

def self.options
  @options ||= default_options
end

.version_informationString

Returns a String containing some platform/version related information.

Returns:

  • (String)


63
64
65
# File 'lib/gem_mirror/cli.rb', line 63

def self.version_information
  "gem_mirror v#{GemMirror::VERSION} on #{RUBY_DESCRIPTION}"
end