Class: Bosh::Gen::Command

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/bosh/gen/cli.rb

Instance Method Summary collapse

Instance Method Details

#errand(name) ⇒ Object



85
86
87
88
89
# File 'lib/bosh/gen/cli.rb', line 85

def errand(name)
  dependencies = options[:dependencies] || []
  require 'bosh/gen/generators/errand_generator'
  Bosh::Gen::Generators::ErrandGenerator.start([name, dependencies])
end

#extract_job(source_package_path) ⇒ Object



108
109
110
111
112
# File 'lib/bosh/gen/cli.rb', line 108

def extract_job(source_package_path)
  source_package_path = File.expand_path(source_package_path)
  require 'bosh/gen/generators/extract_job_generator'
  Bosh::Gen::Generators::ExtractJobGenerator.start([source_package_path])
end

#extract_pkg(source_package_path) ⇒ Object



117
118
119
120
121
# File 'lib/bosh/gen/cli.rb', line 117

def extract_pkg(source_package_path)
  source_package_path = File.expand_path(source_package_path)
  require 'bosh/gen/generators/extract_package_generator'
  Bosh::Gen::Generators::ExtractPackageGenerator.start([source_package_path])
end

#forge(job_name) ⇒ Object



100
101
102
103
# File 'lib/bosh/gen/cli.rb', line 100

def forge(job_name)
  require 'bosh/gen/generators/blacksmith_forge_generator'
  Bosh::Gen::Generators::BlacksmithForgeGenerator.start([job_name])
end

#job(name) ⇒ Object



75
76
77
78
79
80
# File 'lib/bosh/gen/cli.rb', line 75

def job(name)
  dependencies = options[:dependencies] || []
  require 'bosh/gen/generators/job_generator'
  job_type = options[:bpm] ? 'bpm' : 'simple'
  Bosh::Gen::Generators::JobGenerator.start([name, dependencies, job_type])
end

#new(path) ⇒ Object



14
15
16
17
# File 'lib/bosh/gen/cli.rb', line 14

def new(path)
  require 'bosh/gen/generators/new_release_generator'
  Bosh::Gen::Generators::NewReleaseGenerator.start([path])
end

#package(name) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/bosh/gen/cli.rb', line 30

def package(name)
  dependencies = options[:dependencies] || []
  if options[:apt]
    require 'bosh/gen/generators/package_apt_generator'
    Bosh::Gen::Generators::PackageAptGenerator.start([name, dependencies])
  elsif options[:docker_image]
    docker_image = options[:docker_image]
    require 'bosh/gen/generators/package_docker_image_generator'
    Bosh::Gen::Generators::PackageDockerImageGenerator.start([name, docker_image])
  else
    files        = options[:files] || []
    sources      = options[:src] || []
    require 'bosh/gen/generators/package_generator'
    Bosh::Gen::Generators::PackageGenerator.start(
      [name, dependencies, files, sources])
  end
end

#source(name, uri) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/bosh/gen/cli.rb', line 51

def source(name, uri)
  flags = { :blob => options[:blob] || false }
  dir = Dir.mktmpdir
  files = []
  if File.exist?(uri)
    files = [uri]
  else
    say "Downloading #{uri}..."
    FileUtils.chdir(dir) do
      `wget '#{uri}'`
      files = Dir['*'].map {|f| File.expand_path(f)}
    end
  end

  require 'bosh/gen/generators/package_source_generator'
  Bosh::Gen::Generators::PackageSourceGenerator.start(
    [name, files, flags])
end

#template(job_name, file_path) ⇒ Object



93
94
95
96
# File 'lib/bosh/gen/cli.rb', line 93

def template(job_name, file_path)
  require 'bosh/gen/generators/job_template_generator'
  Bosh::Gen::Generators::JobTemplateGenerator.start([job_name, file_path])
end