【发布时间】:2021-12-26 00:17:46
【问题描述】:
如何将以下使用点击与shell + python repl(我认为)的工作示例转换为hy?
python3 - "$@" <<'EOF'
import click
@click.command()
@click.option('--count', default=1, help='Number of greetings.')
@click.option('--name', prompt='Your name',
help='The person to greet.')
def hello(count, name):
"""Simple program that greets NAME for a total of COUNT times."""
for x in range(count):
click.echo('Hello %s!' % name)
if __name__ == '__main__':
hello()
EOF
当我将以下hy 示例与./test.sh --name shadowrylander --count 3 一起使用时,我得到:
Usage: hy [OPTIONS]
Try 'hy --help' for help.
Error: Got unexpected extra argument (-)
我应该得到什么时候:
Hello shadowrylander!
Hello shadowrylander!
Hello shadowrylander!
hy - "$@" <<'EOF'
(import click)
#@(
(.command click)
(.option click "--count" :default 1 :help "Number of greetings")
(.option click "--name" :prompt "Your name" :help "The person to greet.")
(defn hello
[count name]
"""Simple program that greets NAME for a total of COUNT times."""
(for [x (range count)]
(.echo click "Hello %s" % name)))
)
(if (= __name__ "__main__") (hello))
EOF
通常我可以毫无问题地使用hy - "$@" <<'EOF' ... EOF。
【问题讨论】:
标签: python-click hy