2013-12-05 14:00:13 +01:00
|
|
|
======================
|
|
|
|
Command Line Interface
|
|
|
|
======================
|
|
|
|
|
2014-01-25 20:32:56 +01:00
|
|
|
hy
|
|
|
|
--
|
|
|
|
|
2013-12-05 14:00:13 +01:00
|
|
|
Command line options
|
2014-01-25 20:32:56 +01:00
|
|
|
^^^^^^^^^^^^^^^^^^^^
|
2013-12-05 14:00:13 +01:00
|
|
|
|
|
|
|
.. cmdoption:: -c <command>
|
|
|
|
|
|
|
|
Execute the Hy code in *command*.
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
$ hy -c "(print (+ 2 2))"
|
|
|
|
4
|
|
|
|
|
|
|
|
.. cmdoption:: -i <command>
|
|
|
|
|
|
|
|
Execute the Hy code in *command*, then stay in REPL.
|
|
|
|
|
|
|
|
.. cmdoption:: --spy
|
|
|
|
|
2014-01-20 04:29:57 +01:00
|
|
|
Print equivalent Python code before executing. For example::
|
2013-12-05 14:00:13 +01:00
|
|
|
|
|
|
|
=> (defn salutationsnm [name] (print (+ "Hy " name "!")))
|
|
|
|
def salutationsnm(name):
|
|
|
|
return print(((u'Hy ' + name) + u'!'))
|
|
|
|
=> (salutationsnm "YourName")
|
|
|
|
salutationsnm(u'YourName')
|
|
|
|
Hy YourName!
|
|
|
|
=>
|
|
|
|
|
2013-12-06 06:48:50 +01:00
|
|
|
.. versionadded:: 0.9.11
|
|
|
|
|
2013-12-28 14:58:08 +01:00
|
|
|
.. cmdoption:: --show-tracebacks
|
2013-12-27 04:46:48 +01:00
|
|
|
|
|
|
|
Print extended tracebacks for Hy exceptions.
|
|
|
|
|
2013-12-28 14:58:08 +01:00
|
|
|
.. versionadded:: 0.9.12
|
|
|
|
|
2013-12-05 14:00:13 +01:00
|
|
|
.. cmdoption:: -v
|
|
|
|
|
|
|
|
Print the Hy version number and exit.
|
2014-01-25 20:32:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
hyc
|
|
|
|
---
|
|
|
|
|
|
|
|
Command line options
|
|
|
|
^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
.. cmdoption:: file[, fileN]
|
|
|
|
|
|
|
|
Compile Hy code to Python bytecode. For example, save the
|
|
|
|
following code as ``hyname.hy``:
|
|
|
|
|
2014-03-14 14:01:47 +01:00
|
|
|
.. code-block:: hy
|
2014-01-25 20:32:56 +01:00
|
|
|
|
|
|
|
(defn hy-hy [name]
|
|
|
|
(print (+ "Hy " name "!")))
|
|
|
|
|
|
|
|
(hy-hy "Afroman")
|
|
|
|
|
|
|
|
Then run:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
$ hyc hyname.hy
|
|
|
|
$ python hyname.pyc
|
|
|
|
Hy Afroman!
|