Sha256: 559293d5a7f97ad0da25a9ec02698128d440484c73c841062e6d14b0366798e4

Contents?: true

Size: 1.78 KB

Versions: 10

Compression:

Stored size: 1.78 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require "rationalist"
require "uniscribe"

argv = Rationalist.parse(
  ARGV,
  string: '_',
  alias: {
    e: 'encoding',
    v: 'version',
  },
  boolean: [
    'help',
    'version',
    'wide-ambiguous',
  ]
)

if argv[:version]
  puts "uniscribe #{Uniscribe::VERSION} by #{Paint["J-_-L", :bold]} <https://github.com/janlelis/uniscribe>"
  puts "Unicode version is #{Uniscribe::UNICODE_VERSION} (glyph detection #{Uniscribe::UNICODE_VERSION_GLYPH_DETECTION || "[not supported]"})"
  puts "Emoji version is #{Uniscribe::EMOJI_VERSION}"
  exit(0)
end

if argv[:help]
  puts <<-HELP

  #{Paint["DESCRIPTION", :underline]}

  Describes a string of Unicode characters with their name and shows compositions.

  #{Paint["USAGE", :underline]}

  #{Paint["uniscribe", :bold]} [options] data

  --encoding <encoding> | -e | which (Unicode) encoding to use for given data
  --help                |    | this help page
  --version             | -v | displays version of uniscribe
  --wide-ambiguous      |    | ambiguous characters

  #{Paint["COLOR CODING", :underline]}

  #{Paint["blank",      Uniscribe::COLORS[:blank]]}
  #{Paint["control",    Uniscribe::COLORS[:control]]}
  #{Paint["format",     Uniscribe::COLORS[:format]]}
  #{Paint["mark",       Uniscribe::COLORS[:mark]]}
  #{Paint["unassigned", Uniscribe::COLORS[:unassigned]]}
  #{Paint["unassigned and ignorable", Uniscribe::COLORS[:ignorable]]}

  random color for other characters and compositions

  #{Paint["MORE INFO", :underline]}

  https://github.com/janlelis/uniscribe

  HELP
  exit(0)
end

if argv[:_] && argv[:_][0]
  data = argv[:_][0]
elsif !$stdin.tty?
  data = $stdin.read
else
  data = nil
end

begin
  Uniscribe.of(data)
rescue ArgumentError
  $stderr.puts Paint[$!.message, :red]
  exit(1)
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
uniscribe-1.11.1 bin/uniscribe
uniscribe-1.11.0 bin/uniscribe
uniscribe-1.10.0 bin/uniscribe
uniscribe-1.9.0 bin/uniscribe
uniscribe-1.8.0 bin/uniscribe
uniscribe-1.7.0 bin/uniscribe
uniscribe-1.6.0 bin/uniscribe
uniscribe-1.5.1 bin/uniscribe
uniscribe-1.5.0 bin/uniscribe
uniscribe-1.4.0 bin/uniscribe