Class: Bosh::Cli::PublicStemcellPresenter
- Defined in:
- lib/cli/public_stemcell_presenter.rb
Instance Method Summary collapse
- #download(stemcell_name) ⇒ Object
-
#initialize(ui, public_stemcells) ⇒ PublicStemcellPresenter
constructor
A new instance of PublicStemcellPresenter.
- #list(options) ⇒ Object
Constructor Details
#initialize(ui, public_stemcells) ⇒ PublicStemcellPresenter
Returns a new instance of PublicStemcellPresenter.
5 6 7 8 |
# File 'lib/cli/public_stemcell_presenter.rb', line 5 def initialize(ui, public_stemcells) @ui = ui @public_stemcells = public_stemcells end |
Instance Method Details
#download(stemcell_name) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cli/public_stemcell_presenter.rb', line 24 def download(stemcell_name) unless @public_stemcells.has_stemcell?(stemcell_name) @ui.err("'#{stemcell_name}' not found.") end if File.exists?(stemcell_name) && !@ui.confirmed?("Overwrite existing file '#{stemcell_name}'?") @ui.err("File '#{stemcell_name}' already exists") end stemcell = @public_stemcells.find(stemcell_name) download_with_progress = DownloadWithProgress.new(stemcell.url, stemcell.size) download_with_progress.perform @ui.say('Download complete'.make_green) end |
#list(options) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/cli/public_stemcell_presenter.rb', line 10 def list() full = !![:full] stemcells_table = @ui.table do |t| t.headings = full ? %w(Name Url) : %w(Name) stemcell_for().each do |stemcell| t << (full ? [stemcell.name, stemcell.url] : [stemcell.name]) end end @ui.say(stemcells_table.render) @ui.say('To download use `bosh download public stemcell <stemcell_name>`. For full url use --full.') end |