Sha256: 007c22e94bf8746e032118f437e00e6300174f4beab4d4caec764a892fa5f502

Contents?: true

Size: 776 Bytes

Versions: 1

Compression:

Stored size: 776 Bytes

Contents

module Alf
  module Command
    class Show < Alf::Command()
      include Command
    
      options do |opt|
        @renderer = nil
        Renderer.each_renderer do |name,descr,clazz|
          opt.on("--#{name}", "Render output #{descr}"){ 
            @renderer = clazz.new 
          }
        end
      end
        
      def execute(args)
        requester.renderer = (@renderer || requester.renderer || Text::Renderer.new)
        args = [ stdin_reader ] if args.empty?
        args.first
      end
    
      private 

      def stdin_reader
        if requester && requester.respond_to?(:stdin_reader)
          requester.stdin_reader
        else 
          Reader.coerce($stdin)
        end
      end

    end # class Show
  end # module Command
end # module Alf

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alf-0.10.0 lib/alf/command/show.rb