Sha256: d59d27a0573544ed0e67ffa76076bdd65dc5c21819e48ad5ec9d6cc78242dce4

Contents?: true

Size: 818 Bytes

Versions: 1

Compression:

Stored size: 818 Bytes

Contents

module StackFu
  class ListCommand < Command
    include ApiHooks
  
    def default(parameters, options)
      user = User.find(:all).first
      items = spinner { 
        [
          Stack.find(:all, :conditions => { "user.id" => user.id }), 
          Plugin.find(:all, :conditions => { "user.id" => user.id })
        ].flatten
      }
      
      params = {
        :class => [Stack, Plugin], 
        :collection => items,
        :display => [:name, :type, :description],
        :main_column => :name,
        :empty => "You have nothing to list yet. To generate stacks or plugins, try the 'stackfu generate' command.",
        :ansi => options[:plain].nil?
      }

      puts table(params) { |item| [item.name, item.class.name.demodulize.downcase, item.description.try(:truncate_words)] }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stackfu-0.1.0 lib/stackfu/commands/list_command.rb