Sha256: ea7c1f1f6783dd9376673704b02901457909ff6da72e6c3cec43a676a39a293a

Contents?: true

Size: 488 Bytes

Versions: 4

Compression:

Stored size: 488 Bytes

Contents

require 'thor'
require 'pp'

module GoogleWebTranslate
  # Command line interface
  class CLI < Thor
    desc 'string from to', 'translate a string from one language to another'
    method_option :dt, type: :array, desc: 'data types'
    def translate(string, from, to)
      api_options = { debug: ENV['DEBUG'] }
      api_options[:dt] = options[:dt] if options[:dt]

      api = API.new(api_options)
      result = api.translate(string, from, to)
      pp result.to_h
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
google_web_translate-0.2.5 lib/google_web_translate/cli.rb
google_web_translate-0.2.4 lib/google_web_translate/cli.rb
google_web_translate-0.2.3 lib/google_web_translate/cli.rb
google_web_translate-0.2.1 lib/google_web_translate/cli.rb