class Shift::CLI

The ‘shifter` command line interface.

Constants

USAGE

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/shift/cli.rb, line 16
def self.new
  begin
    super(*ARGV)
  rescue ArgumentError
    abort USAGE
  end
end
new(path, a=nil, b=nil) click to toggle source
# File lib/shift/cli.rb, line 24
def initialize(path, a=nil, b=nil)
  @path = path
  @format, @action = stdin? ? [a,b] : [b,a]
  @format ||= :echo
  @action ||= :default
end

Public Instance Methods

data() click to toggle source
# File lib/shift/cli.rb, line 35
def data
  stdin? ? STDIN.read : File.read(@path)
end
run!() click to toggle source
# File lib/shift/cli.rb, line 39
def run!
  puts Shift(data, @format).process(@action)
end
stdin?() click to toggle source
# File lib/shift/cli.rb, line 31
def stdin?
  @path == '-'
end