2013-12-05 14:00:13 +01:00
|
|
|
======================
|
|
|
|
Command Line Interface
|
|
|
|
======================
|
|
|
|
|
2014-04-10 06:45:11 +02:00
|
|
|
.. _hy:
|
|
|
|
|
2014-01-25 20:32:56 +01:00
|
|
|
hy
|
|
|
|
--
|
|
|
|
|
2014-12-06 21:28:28 +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.
|
|
|
|
|
2014-11-23 23:05:20 +01:00
|
|
|
.. cmdoption:: -m <module>
|
|
|
|
|
|
|
|
Execute the Hy code in *module*, including ``defmain`` if defined.
|
|
|
|
|
|
|
|
The :option:`-m` flag terminates the options list so that
|
|
|
|
all arguments after the *module* name are passed to the module in
|
|
|
|
``sys.argv``.
|
|
|
|
|
2015-05-09 21:12:04 +02:00
|
|
|
.. versionadded:: 0.11.0
|
2014-11-23 23:05:20 +01:00
|
|
|
|
2013-12-05 14:00:13 +01:00
|
|
|
.. cmdoption:: --spy
|
|
|
|
|
2016-09-22 14:20:26 +02:00
|
|
|
Print equivalent Python code before executing in REPL. 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!
|
|
|
|
=>
|
|
|
|
|
2016-09-22 14:20:26 +02:00
|
|
|
`--spy` only works on REPL mode.
|
2013-12-06 06:48:50 +01:00
|
|
|
.. versionadded:: 0.9.11
|
|
|
|
|
2017-04-01 07:10:45 +02:00
|
|
|
.. cmdoption:: --repl-output-fn
|
|
|
|
|
|
|
|
Format REPL output using specific function (e.g., hy.contrib.hy-repr.hy-repr)
|
|
|
|
|
|
|
|
.. versionadded:: 0.13.0
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2014-04-10 06:45:11 +02:00
|
|
|
.. _hyc:
|
|
|
|
|
2014-01-25 20:32:56 +01:00
|
|
|
hyc
|
|
|
|
---
|
|
|
|
|
2014-12-07 07:05:52 +01:00
|
|
|
Command Line Options
|
2014-01-25 20:32:56 +01:00
|
|
|
^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
.. 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!
|
2014-04-10 06:45:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
.. _hy2py:
|
|
|
|
|
|
|
|
hy2py
|
|
|
|
-----
|
|
|
|
|
|
|
|
.. versionadded:: 0.10.1
|
|
|
|
|
2014-12-07 07:05:52 +01:00
|
|
|
Command Line Options
|
2014-04-10 06:45:11 +02:00
|
|
|
^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
.. cmdoption:: -s
|
|
|
|
--with-source
|
|
|
|
|
|
|
|
Show the parsed source structure.
|
|
|
|
|
|
|
|
.. cmdoption:: -a
|
|
|
|
--with-ast
|
|
|
|
|
|
|
|
Show the generated AST.
|
|
|
|
|
|
|
|
.. cmdoption:: -np
|
|
|
|
--without-python
|
|
|
|
|
|
|
|
Do not show the Python code generated from the AST.
|