Sha256: 36c88f767f3118b311043bf162af9a9cb106e577e559827ef720f926ba551fd9

Contents?: true

Size: 1.71 KB

Versions: 41

Compression:

Stored size: 1.71 KB

Contents

require "thor"

module Emot
  class CLI < Thor
    desc "show [NAME]", "show emoji icon and unicode for NAME"
    option :only, aliases:'-o', desc:"set 'name', 'code' or 'icon'"
    option :inline, aliases:'-i', default:false, type: :boolean
    def show(name=nil)
      case name
      when nil, 'all'
        list =
          Emot.list.map do |name, (icon, code)|
            case options[:only]
            when 'name'
              "%s  %s" % [icon, c(name)]
            when 'code', 'unicode'
              "%s  %s" % [icon, code]
            when 'emoji', 'icon'
              "%s" % [icon]
            when 'nameonly'
              "%s" % [c(name)]
            else
              "%s  %s (%s)" % [icon ,c(name), code]
            end
          end
        puts (options[:inline] ? list.join("  ") : list)
        puts "\e[33m#{list.size}\e[0m #{c('emojis')}"
      else
        icon, code = Emot.list[name.intern]
        if icon
          print "%s  %s (%s)\n" % [icon, c(name), code]
        else
          puts "No emoji for '#{name}'"
        end
      end
    end

    desc "icons", "show all emoji icons"
    option :inline, aliases:'-i', default:true, type: :boolean
    def icons
      CLI.start(['show', '--only', 'emoji', '--inline', options[:inline].to_s])
    end

    desc "names", "show all available names for emoji"
    option :inline, aliases:'-i', default:false, type: :boolean
    def names
      CLI.start(['show', '--only', 'nameonly', '--inline', options[:inline].to_s])
    end

    desc "version", "Show Emot version"
    def version
      puts "Emot #{Emot::VERSION} (c) 2014 kyoendo"
    end
    map "-v" => :version

    no_tasks do
      def c(str, color=32)
        "\e[#{color}m#{str}\e[0m"
      end
    end
  end
end

Version data entries

41 entries across 26 versions & 2 rubygems

Version Path
tdiary-5.2.4 vendor/bundle/ruby/3.1.0/gems/emot-0.0.4/lib/emot/cli.rb
tdiary-5.2.3 vendor/bundle/ruby/3.1.0/gems/emot-0.0.4/lib/emot/cli.rb
tdiary-5.2.2 vendor/bundle/ruby/3.1.0/gems/emot-0.0.4/lib/emot/cli.rb
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/emot-0.0.4/lib/emot/cli.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/emot-0.0.4/lib/emot/cli.rb
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/emot-0.0.4/lib/emot/cli.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/emot-0.0.4/lib/emot/cli.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/emot-0.0.4/lib/emot/cli.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/emot-0.0.4/lib/emot/cli.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/emot-0.0.4/lib/emot/cli.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/emot-0.0.4/lib/emot/cli.rb
tdiary-5.1.6 vendor/bundle/ruby/3.0.0/gems/emot-0.0.4/lib/emot/cli.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/2.7.0/gems/emot-0.0.4/lib/emot/cli.rb
tdiary-5.1.5 vendor/bundle/ruby/2.7.0/gems/emot-0.0.4/lib/emot/cli.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/emot-0.0.4/lib/emot/cli.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/emot-0.0.4/lib/emot/cli.rb
tdiary-5.1.4 vendor/bundle/ruby/2.7.0/gems/emot-0.0.4/lib/emot/cli.rb
tdiary-5.1.3 vendor/bundle/ruby/2.6.0/gems/emot-0.0.4/lib/emot/cli.rb
tdiary-5.1.3 vendor/bundle/ruby/2.7.0/gems/emot-0.0.4/lib/emot/cli.rb
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/emot-0.0.4/lib/emot/cli.rb