如何将以下使用 click with shell + python repl
(I think) 的工作示例转换为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
毫无问题地使用。