Module: Cabal::CLI

Defined in:
lib/cabal/cli.rb,
lib/cabal/cli/key.rb,
lib/cabal/cli/ssh.rb,
lib/cabal/cli/list.rb,
lib/cabal/cli/main.rb,
lib/cabal/cli/authenticated.rb

Overview

Bootstrap and configure the CLI application

Defined Under Namespace

Modules: Authenticated Classes: Key, List, Main, SSH

Constant Summary collapse

NoConfig =

The expected config file does not exist

Class.new(StandardError)
NoURLDefinition =

The config file does not contain a :url

Class.new(StandardError)
NoPrivateConfig =

The config file does not contain :access_key and :secret_key

Class.new(StandardError)

Class Method Summary collapse

Class Method Details

.cabal_ymlString

Calculates the expected path of the Cabal config file

Returns:

  • (String)

    the config file path



22
23
24
# File 'lib/cabal/cli.rb', line 22

def self.cabal_yml
  File.expand_path(File.join(ENV['HOME'], '.cabal.yml'))
end

.configHash

The global config for the CLI

Returns:

  • (Hash)

    the current configuration



40
41
42
# File 'lib/cabal/cli.rb', line 40

def self.config
  @config ||= {}
end

.resetnil

Clears the global configuration

Returns:

  • (nil)


46
47
48
# File 'lib/cabal/cli.rb', line 46

def self.reset
  @config = {}
end

.setupnil

Parses the config file and sets up the global configuration

Returns:

  • (nil)


28
29
30
31
32
33
34
35
36
# File 'lib/cabal/cli.rb', line 28

def self.setup
  if File.exist?(cabal_yml)
    @config = YAML.load(File.read(cabal_yml))

    raise NoURLDefinition.new("#{cabal_yml} must contain a :url: definition") unless config[:url]
  else
    raise NoConfig.new("Please create #{cabal_yml} and try again")
  end
end