class Togglate::CLI
Public Instance Methods
append_code(file)
click to toggle source
# File lib/togglate/cli.rb, line 27 def append_code(file) text = File.read(file) opts = symbolize_keys(options) method = opts.delete(:method) code = Togglate.append_code(method, opts) puts "#{text}\n#{code}" rescue => e STDERR.puts "something go wrong. #{e}" exit end
commentout(file)
click to toggle source
# File lib/togglate/cli.rb, line 41 def commentout(file) text = File.read(file) comments, remains = Togglate.commentout(text, tag:options['tag']) puts options['remains'] ? remains : comments rescue => e STDERR.puts "something go wrong. #{e}" exit end
create(file)
click to toggle source
# File lib/togglate/cli.rb, line 12 def create(file) text = File.read(file) opts = symbolize_keys(options) blocks = %i(fenced liquid) opts.update(wrap_exceptions:blocks) if opts[:code_block] opts.update(translate:nil) if opts[:translate].empty? puts Togglate.create(text, opts) rescue => e STDERR.puts "something go wrong. #{e}" exit end
symbolize_keys(options)
click to toggle source
# File lib/togglate/cli.rb, line 57 def symbolize_keys(options) options.inject({}) do |h, (k,v)| h[k.intern] = case v when Hash then symbolize_keys(v) else v end h end end
version()
click to toggle source
# File lib/togglate/cli.rb, line 51 def version puts "Togglate #{Togglate::VERSION} (c) 2014 kyoendo" end