Class: Omnibus::CLI

Inherits:
Omnibus::Command::Base show all
Defined in:
lib/omnibus/cli.rb

Defined Under Namespace

Classes: Runner

Instance Method Summary collapse

Methods inherited from Omnibus::Command::Base

dispatch, exit_on_failure?, #help, #initialize

Methods included from Logging

included

Constructor Details

This class inherits a constructor from Omnibus::Command::Base

Instance Method Details

#build(name) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/omnibus/cli.rb', line 78

def build(name)
  manifest = if @options[:use_manifest]
               Omnibus::Manifest.from_file(@options[:use_manifest])
             else
               nil
             end

  project = Project.load(name, manifest)
  say("Building #{project.name} #{project.build_version}...")
  Omnibus::S3Cache.populate if @options[:populate_s3_cache] && !Omnibus::S3Cache.fetch_missing.empty?
  begin
    project.download
  rescue
    Config.use_s3_caching(false) if Config.use_s3_caching
    project = Project.load(name, nil)
    project.download
  end
  project.build

  if @options[:output_manifest]
    FileUtils.mkdir_p("pkg")
    File.open(::File.join("pkg", "version-manifest.json"), "w") do |f|
      f.write(FFI_Yajl::Encoder.encode(project.built_manifest.to_hash, pretty: true))
    end
  end
end

#listObject



168
169
170
171
172
173
174
175
176
177
# File 'lib/omnibus/cli.rb', line 168

def list
  if Omnibus.projects.empty?
    say("There are no Omnibus projects!")
  else
    say("Omnibus projects:")
    Omnibus.projects.sort.each do |project|
      say("  * #{project.name} (#{project.build_version})")
    end
  end
end

#manifest(name) ⇒ Object



128
129
130
131
132
133
134
135
136
# File 'lib/omnibus/cli.rb', line 128

def manifest(name)
  # Override ohai information
  Ohai["os"] = @options[:os] if @options[:os]
  Ohai["platform_family"] = @options[:platform_family] if @options[:platform_family]
  Ohai["platform"] = @options[:platform] if @options[:platform]
  Ohai["platform_version"] = @options[:platform_version] if @options[:platform_version]
  Ohai["kernel"]["machine"] = @options[:architecture] if @options[:architecture]
  puts FFI_Yajl::Encoder.encode(Project.load(name).built_manifest.to_hash, pretty: true)
end

#versionObject



193
194
195
# File 'lib/omnibus/cli.rb', line 193

def version
  say("Omnibus v#{Omnibus::VERSION}")
end