Class: Spongebobify::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/spongebobify/cli.rb

Instance Method Summary collapse

Instance Method Details

#spongebobify(input = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/spongebobify/cli.rb', line 9

def spongebobify(input = nil)
  if input.nil? && $stdin.tty?
    puts "No input provided. Use 'spongebobify \"some text\"' or 'spongebobify ./path_to_file.txt'"
    exit 1
  end

  if File.exist?(input)
    text = File.read(input)
  else
    text = input
  end

  puts Spongebobify.process(text)
end