Class: Bellboy::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/bellboy/cli.rb

Overview

Simple CLI. Mirrors the Berkshelf options & commands where possible.

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Cli

Returns a new instance of Cli.



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/bellboy/cli.rb', line 24

def initialize(*args)
  super(*args)

  Bellboy.logger = Bellboy::Logger.new(options)

  if @options[:config]
    unless File.exist?(@options[:config])
      raise ConfigNotFound, @options[:config]
    end
      Berkshelf::Config.set_path(@options[:config])
    end
end

Instance Method Details

#installObject



80
81
82
83
# File 'lib/bellboy/cli.rb', line 80

def install
  berksfile = Bellboy.berks_from_file(options[:berksfile])
  Bellboy::Installer.install(berksfile, options)
end

#listObject



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/bellboy/cli.rb', line 126

def list
  berksfile = Bellboy.berks_from_file(options[:berksfile])
  databags = Bellboy.list(berksfile)

  if options[:json]
    Bellboy.logger.log databags.to_json
  else
    databags.each do |bag, items|
      Bellboy.logger.log options[:bags] ? bag : "#{bag}:"

      items.each do |item|
        Bellboy.logger.log "\t#{item}"
      end unless options[:bags]
    end
  end

end

#uploadObject



98
99
100
101
# File 'lib/bellboy/cli.rb', line 98

def upload
  berksfile = Bellboy.berks_from_file(options[:berksfile])
  Bellboy::Uploader.upload(berksfile, options)
end

#versionObject



59
60
61
62
63
64
65
# File 'lib/bellboy/cli.rb', line 59

def version
  berksfile = Bellboy.berks_from_file(options[:berksfile])

  version_options = options.reverse_merge(verbose: false)

  Bellboy::Versioner.version(berksfile, version_options)
end