require 'app42/command/user_key' module App42 module Command class Info < Base # # show detailed app information # #Examples: # # $ app42 info --app APP # === Demo info # Memory 512 # Framework rails # Runtime ruby20 # Domain demo.app42paas.com # User jon # Status running # def info @options[:name] = get_app_name if @options[:name].nil? rows, rows_header_final, rows_header = [], [], nil app_info = app_information 'app', @options[:name] if app_info && app_info['appInfo'] rows_header = app_info['appInfo'].keys rows << app_info['appInfo'].values rows_header.map { |e| rows_header_final << camel_case_to_whitespace(e) } table = Terminal::Table.new :title => Paint["=== #{@options[:name]} Info ===", :green], :headings => rows_header_final, :rows => rows puts table end end # show app status information # #Examples: # # $ app42 status --app APP #=== Demo status # running # def state @options[:name] = get_app_name if @options[:name].nil? rows = [] rows_header = nil app_status = app_information 'app', @options[:name] rows_header = Array('State') rows << Array(app_status['appInfo']['appStatus']) table = Terminal::Table.new :title => Paint["=== #{@options[:name]} State ===", :green], :rows => rows puts table end # Returns the log URLs for the application def logs @options[:name] = get_app_name if @options[:name].nil? app_logs = app_information 'app/logs', @options[:name] if is_app_exist? @options[:name] rows, rows_header = [], nil rows_header = 'Log URL(s)' app_logs['logUrls'].each do |log| rows << Array(log) end message "#{Message::LOG_MESSAGE}", true, 'green' table = Terminal::Table.new :title => rows_header, :rows => rows puts table end # # list releases # #Examples: # # $ app42 releases --app APP # === Demo releases # Version v1 # # Email test@gmail.com # # Date 20/02/2010 # #TODO , NEED TO SYNC WITH SERVICE def releases @options[:name] = get_app_name if @options[:name].nil? app_releases = app_information 'releases', @options[:name] puts Paint["=== #{@options[:name]} releases ===", :green] app_releases['releaseInfo'].each do |release| release.each_pair do |key, value| print Paint["#{key.capitalize}", :bright] print Paint[" #{value}\n", :bright] end end if app_releases['releaseInfo'] print_new_line end end end end