Metadata-Version: 2.4
Name: quotish
Version: 0.1.0
Summary: Build command lines and shell snippets using template strings
License-Expression: MPL-2.0
Project-URL: Repository, https://codeberg.org/refi64/quotish
Project-URL: Issues, https://codeberg.org/refi64/quotish/issues
Project-URL: Documentation, https://quotish.readthedocs.io/
Classifier: Development Status :: 3 - Alpha
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: System :: Shells
Requires-Python: >=3.14
Description-Content-Type: text/x-rst
License-File: LICENSE
Dynamic: license-file

quotish
=======

.. image:: https://img.shields.io/pypi/v/quotish?style=for-the-badge
   :alt: PyPI version
.. image:: https://app.readthedocs.org/projects/quotish/badge/?style=for-the-badge
   :alt: Documentation status

quotish is a combinator library for building command lines and shell snippets
using PEP 750 template strings. Grab it from `PyPI
<https://pypi.org/project/quotish/>`_ or read the `documentation on ReadTheDocs
<https://quotish.readthedocs.io/>`_.

.. code-block:: python

  >>> import quotish as qsh
  >>> # Safely interpolate values into argument lists or shell-safe strings.
  >>> msg = 'hello, world'
  >>> qsh.cmd(t'echo {msg}!').argv()
  ['echo', 'hello, world!']
  >>> qsh.cmd(t'echo {msg}!').render()
  "echo 'hello, world!'"
  >>> # Interpolate into shell lines instead to preserve shell syntax constructs.
  >>> qsh.shell(t'echo {msg}; echo 123').render()
  "echo 'hello, world'; echo 123"
  >>> # Unpack sequences, build cartesian products, and compose the resulting
  >>> # command lines together.
  >>> host = 'host'
  >>> pkgs = ['ripgrep', 'just']
  >>> dnf = qsh.cmd(t'dnf install -y {pkgs:*}')
  >>> inner = qsh.shell(rt"echo '- '{pkgs:^}$'\n' ; {dnf:*}")
  >>> qsh.cmd(t'ssh {host} {inner}').argv()
  ['ssh', 'host', "echo '- 'ripgrep$'\\n' '- 'just$'\\n' ; dnf install -y ripgrep just"]
