1
1
mirror of https://github.com/wader/fq.git synced 2024-10-27 04:09:37 +03:00

Merge pull request #377 from wader/force-unicode

interp: Add --unicode-output/-U to force use of unicode
This commit is contained in:
Mattias Wadman 2022-08-17 21:49:40 +02:00 committed by GitHub
commit ff29fe7154
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

View File

@ -203,7 +203,12 @@ def _opt_eval($rest):
then true
else null
end
)
),
unicode: (
if .unicode_output == true then true
else null
end
),
}
| with_entries(select(.value != null))
);
@ -473,6 +478,12 @@ def _opt_cli_opts:
description: "Slurp all inputs into an array or string (-Rs)",
bool: true
},
"unicode_output": {
short: "-U",
long: "--unicode-output",
description: "Force unicode output",
bool: true
},
"show_version": {
short: "-v",
long: "--version",

View File

@ -39,6 +39,7 @@ Example usages:
--raw-output,-r Raw string output (without quotes)
--repl,-i Interactive REPL
--slurp,-s Slurp all inputs into an array or string (-Rs)
--unicode-output,-U Force unicode output
--version,-v Show version
$ fq -i
null> ^D

9
pkg/interp/testdata/unicode.fqtest vendored Normal file
View File

@ -0,0 +1,9 @@
$ _STDOUT_IS_TERMINAL=0 NO_COLOR= CLIUNICODE=1 fq -n '[123] | hexdump'
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|
0x0|7b| |{| |.: raw bits 0x0-0x0.7 (1)
$ _STDOUT_IS_TERMINAL=1 NO_COLOR= CLIUNICODE=1 fq -n '[123] | hexdump'
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f│0123456789abcdef│
0x0│7b│ │{│ │.: raw bits 0x0-0x0.7 (1)
$ NO_COLOR=1 fq -Un '[123] | hexdump'
│00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f│0123456789abcdef│
0x0│7b│ │{│ │.: raw bits 0x0-0x0.7 (1)