Class: Mamiya::CLI
- Inherits:
-
Thor
- Object
- Thor
- Mamiya::CLI
- Defined in:
- lib/mamiya/cli.rb,
lib/mamiya/cli/client.rb
Defined Under Namespace
Classes: Client
Instance Method Summary collapse
- #agent ⇒ Object
- #build ⇒ Object
- #distribute ⇒ Object
- #extract(package_atom, destination) ⇒ Object
- #fetch(package_atom, destination) ⇒ Object
- #list_applications ⇒ Object
- #list_packages ⇒ Object
- #master ⇒ Object
- #prepare(target) ⇒ Object
- #prune(nums_to_keep) ⇒ Object
- #push(package_atom) ⇒ Object
- #show(package) ⇒ Object
- #switch(target) ⇒ Object
Instance Method Details
#agent ⇒ Object
202 203 204 205 206 207 208 209 |
# File 'lib/mamiya/cli.rb', line 202 def agent prepare_agent_behavior! merge_serf_option! override_labels! @agent = Agent.new(config, logger: logger) @agent.run! end |
#build ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/mamiya/cli.rb', line 93 def build # TODO: overriding name i(build_from build_to).each { |k| script.set(k, File.([k])) if [k] } if [:force_prepare_build] && [:skip_prepare_build] logger.warn 'Both force_prepare_build and skip_prepare_build are enabled. ' \ 'This results skipping prepare_build...' end if [:force_prepare_build] script.set :skip_prepare_build, false end if [:skip_prepare_build] script.set :skip_prepare_build, true end builder = Mamiya::Steps::Build.new(script: script, logger: logger) builder.run! if [:push] package = builder.package push(package.name) end end |
#distribute ⇒ Object
167 168 |
# File 'lib/mamiya/cli.rb', line 167 def distribute end |
#extract(package_atom, destination) ⇒ Object
157 158 159 160 161 162 163 164 |
# File 'lib/mamiya/cli.rb', line 157 def extract(package_atom, destination) package_path = package_path_from_atom(package_atom) Mamiya::Steps::Extract.new( package: package_path, destination: destination ).run! end |
#fetch(package_atom, destination) ⇒ Object
146 147 148 149 150 151 152 153 154 |
# File 'lib/mamiya/cli.rb', line 146 def fetch(package_atom, destination) Mamiya::Steps::Fetch.new( script: script(:no_error), config: config, package: package_atom, application: application, destination: destination, ).run! end |
#list_applications ⇒ Object
63 64 65 |
# File 'lib/mamiya/cli.rb', line 63 def list_applications puts _applications.keys end |
#list_packages ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/mamiya/cli.rb', line 53 def list_packages unless [:name_only] puts "Available packages in #{application}:" puts "" end puts storage.packages.sort end |
#master ⇒ Object
216 217 218 219 220 221 222 |
# File 'lib/mamiya/cli.rb', line 216 def master prepare_agent_behavior! merge_serf_option! @agent = Master.new(config, logger: logger) @agent.run! end |
#prepare(target) ⇒ Object
172 173 174 175 176 177 178 179 |
# File 'lib/mamiya/cli.rb', line 172 def prepare(target) Mamiya::Steps::Prepare.new( script: nil, config: config, target: target, labels: labels, ).run! end |
#prune(nums_to_keep) ⇒ Object
136 137 138 139 140 141 142 143 |
# File 'lib/mamiya/cli.rb', line 136 def prune(nums_to_keep) puts "Pruning packages from #{application} (keeping last #{nums_to_keep.to_i} packages)..." removed = storage.prune(nums_to_keep.to_i) puts "Pruned #{removed.size} packages:" puts removed.join(?\n) end |
#push(package_atom) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/mamiya/cli.rb', line 120 def push(package_atom) package_path = package_path_from_atom(package_atom) if [:application] logger.warn "Overriding package's application name with given one: #{options[:application]}" sleep 2 end Mamiya::Steps::Push.new( config: config, package: package_path, application: [:application], ).run! end |
#show(package) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/mamiya/cli.rb', line 69 def show(package) = storage.(package) case [:format] when 'pp' require 'pp' pp when 'json' require 'json' puts .to_json when 'yaml' require 'yaml' puts .to_yaml end end |
#switch(target) ⇒ Object
184 185 186 187 188 189 190 191 192 |
# File 'lib/mamiya/cli.rb', line 184 def switch(target) Mamiya::Steps::Switch.new( script: nil, config: config, target: target, labels: labels, no_release: [:no_release], ).run! end |