fix: v0.4.1 — read stdin as UTF-8 (section --content - got mojibake from the frozen exe)

This commit is contained in:
olivier committed 2026-10-19 12:01:54 -04:00
1 parent d063551a1e
commit 34d28c03fa
2 files changed
+24 -4

No files matched your search

+5 -4
View File
@@ -1214,7 +1214,7 @@ def _periodic_output_options(command):
help="Don't open Obsidian; a newly created note keeps raw Templater syntax "
"until Obsidian processes it")(command)
@click.version_option(version='0.4.0', prog_name='onyx')
@click.version_option(version='0.4.1', prog_name='onyx')
@click.group(name='onyx')
def cli():
"""Onyx - Interact with Obsidian vaults from the command line
@@ -1559,9 +1559,10 @@ def frontmatter_command(note_name, edit, view, clear, delete, add, remove, key,
cli.frontmatter_list_items(note_name, key[0], value, remove=remove, vault=vault)
if __name__ == '__main__':
# Scripts read onyx's output (e.g. `--print-path`): emit UTF-8 with LF on every OS.
# Without this, Windows pipes get the ANSI code page (é -> 0xE9; PyInstaller ignores
# PYTHONUTF8) and CRLF, whose trailing \r survives bash's $(...).
# Scripts talk to onyx through pipes (`--content -`, `--print-path`): UTF-8 with LF on
# every OS. Without this, Windows pipes use the ANSI code page (é -> 0xE9 out, UTF-8 in
# read as "é"; PyInstaller ignores PYTHONUTF8) and CRLF, whose \r survives bash's $(...).
sys.stdin.reconfigure(encoding='utf-8')
for stream in (sys.stdout, sys.stderr):
stream.reconfigure(encoding='utf-8', newline='\n')
cli()