bin/unibits in unibits-1.0.0 vs bin/unibits in unibits-1.1.0
- old
+ new
@@ -5,41 +5,76 @@
argv = Rationalist.parse(
ARGV,
string: '_',
alias: {
- e: 'encoding',
c: 'convert',
+ e: 'encoding',
v: 'version',
+ w: 'width',
},
boolean: [
'help',
+ 'stats',
'version',
- 'stats'
+ 'wide-ambiguous',
],
default: {
stats: true
},
)
if argv[:version]
- puts Unibits::VERSION
+ puts "unibits #{Unibits::VERSION} by #{Paint["J-_-L", :bold]} <https://github.com/janlelis/unibits>"
exit(0)
end
if argv[:help]
puts <<-HELP
+ #{Paint["DESCRIPTION", :underline]}
+
+ Visualizes ANSI and variouus Unicode encodings in the terminal.
+
#{Paint["USAGE", :underline]}
- #{Paint["unibits", :bold]} [--encoding <encoding>] [--convert <encoding>] [--no-stats] data
+ #{Paint["unibits", :bold]} [options] data
- Supported encodings: #{Unibits::SUPPORTED_ENCODINGS.join(', ')}
- Explanation of stats: bytes / codepoints / glyphs / expected terminal width
+ --encoding <encoding> | -e | which encoding to use for given data
+ --convert <encoding> | -c | which encoding to convert to (if possible)
+ --width <n> | -w | force a specific number of terminal columns
+ --no-stats | | no stats header with length info
+ --version | | displays version of unibits
+ --wide-ambiguous | | ambiguous characters
- More info and examples at: https://github.com/janlelis/unibits
+ #{Paint["ENCODINGS", :underline]}
+ #{Unibits::SUPPORTED_ENCODINGS.join(', ')}
+
+ #{Paint["STATS", :underline]}
+
+ ( bytes / codepoints / glyphs / expected terminal width )
+
+ #{Paint["INVALID BYTES", :underline]}
+
+ UTF-8
+
+ n.e.con. | not enough continuation bytes
+ unexp.c. | unexpected continuation byte
+ toolarge | codepoint value exceeds maximum allowed (U+10FFFF)
+ sur.gate | codepoint value would be a surrogate half
+ overlong | unnecessary null padding
+
+ UTF-16
+
+ incompl. | not enough bytes left to finish codepoint
+ hlf.srg. | other half of surrogate missing
+
+ #{Paint["MORE INFO", :underline]}
+
+ https://github.com/janlelis/unibits
+
HELP
exit(0)
end
if argv[:_] && argv[:_][0]
@@ -49,10 +84,17 @@
else
data = nil
end
begin
- Unibits.of(data, encoding: argv[:encoding], convert: argv[:convert], stats: argv[:stats])
+ Unibits.of(
+ data,
+ encoding: argv[:encoding],
+ convert: argv[:convert],
+ stats: argv[:stats],
+ wide_ambiguous: argv[:'wide-ambiguous'],
+ width: argv[:width],
+ )
rescue ArgumentError
$stderr.puts Paint[$!.message, :red]
exit(1)
end