Sha256: e825c1e9c68c15312dfe5bc10edee814403d76acae8d6a9a04c88171e786baf7

Contents?: true

Size: 714 Bytes

Versions: 5

Compression:

Stored size: 714 Bytes

Contents

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'command_lion'
require 'pry'

CommandLion::App.run do
  # ...
  command :read_stdin do
    flag "--read"
    type :stdin_stream
    action do
      # Separate into two operations to make it faster.
      if options[:filter].given?
        # Filter lines that contain string.
        inclusive = options[:filter].argument
        arguments do |argument|
          next unless argument.include?(inclusive)
          puts argument
        end
      else
        # Just print lines. 
        arguments do |argument|
          puts argument
        end
      end
    end
    option :filter do
      flag "--filter"
      type :string
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
command_lion-2.0.1 examples/read.rb
command_lion-2.0.0 examples/read.rb
command_lion-1.0.4 examples/read.rb
command_lion-1.0.3geff examples/read.rb
command_lion-1.0.3 examples/read.rb