我正在编写一个 git pre-commit 钩子,但它需要用户输入,并且钩子不在交互式终端中运行。使用 Python,我可以执行以下操作来访问用户输入:
#!/usr/bin/python
import sys
# This is required because git hooks are run in non-interactive
# mode. You aren't technically supposed to have access to stdin.
# This hack works on MaxOS and Linux. Mileage may vary on Windows.
sys.stdin = open('/dev/tty')
result = input("Gimme some input: ")
在 Crystal 中执行此操作的适当方法是什么?