Sha256: 4039849a415c6119fc5181b671177d21bc31ebb5440006de6288088d1357dc63

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

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

require "thor"

module NATOPhone
  class NATOPhoneCLI < Thor

    desc "encode WORD(S)", "Encode to NATO alphabet"
    map "-E" => "encode"
    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}\n\n"
      end
    end

    desc "decode NATO", "Decode from NATO alphabet"
    map "-D" => "decode"
    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}\n\n"
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
natophone-0.0.3 lib/cli.rb