Sha256: d0eb818bbd7d33716995f4b7625cf68ee7828f8c09e035062243a954440caae3

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

#!/usr/bin/env ruby
# coding: UTF-8

require "thor"

module NATOPhone
  class NATOPhoneCLI < Thor

    desc "encode WORD(S)", "Encode to NATO alphabet"
    option :yell, aliases: '-Y', type: :boolean, desc: "Option to YELL the translation"
    option :json, aliases: '-J', type: :boolean, desc: "Option to export the translation in JSON"
    def encode(*args)
      enc = NATOPhone::Encoder.new(args)
      if options[:yell]
        puts "\n#{enc.yell}\n\n"
      elsif options[:json]
        puts enc.to_json
      else
        puts "\n#{enc.translate}\n\n"
      end
    end

    desc "decode NATO", "Decode from NATO alphabet"
    option :yell, aliases: '-Y', type: :boolean, desc: "Option to YELL the translation"
    option :json, aliases: '-J', type: :boolean, desc: "Option to export the translation in JSON"
    def decode(*args)
      dec = NATOPhone::Decoder.new(args)
      if options[:yell]
        puts "\n#{dec.yell}\n\n"
      elsif options[:json]
        puts dec.to_json
      else
        puts "\n#{dec.translate}\n\n"
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
natophone-0.0.2 lib/cli.rb