|
| 1 | +Command-line interface |
| 2 | +====================== |
| 3 | + |
| 4 | +Installing pyStrich exposes a ``pystrich`` console script with a subcommand |
| 5 | +per format and PNG / SVG / EPS / ASCII / terminal / DXF output. |
| 6 | + |
| 7 | +.. code-block:: console |
| 8 | +
|
| 9 | + $ pystrich qrcode --text "https://en.wikipedia.org/wiki/Jasper,_Missouri" -o jasper.svg |
| 10 | + $ pystrich code128 --text "Dalton" -o dalton.png |
| 11 | + $ pystrich ean13 --text "5050070007664" -o ean13.png |
| 12 | + $ echo "DLB 573" | pystrich code39 -o code39.png |
| 13 | + $ pystrich datamatrix --text "Rausschmeißer" # terminal preview |
| 14 | +
|
| 15 | +The last example produces: |
| 16 | + |
| 17 | +.. literalinclude:: examples/datamatrix-rausschmeisser-terminal.txt |
| 18 | + :language: text |
| 19 | + :class: terminal-art |
| 20 | + |
| 21 | +Reference |
| 22 | +--------- |
| 23 | + |
| 24 | +.. argparse:: |
| 25 | + :module: pystrich.cli |
| 26 | + :func: _build_parser |
| 27 | + :prog: pystrich |
| 28 | + |
| 29 | +Format auto-detection |
| 30 | +--------------------- |
| 31 | + |
| 32 | +The output format is auto-detected from the ``-o`` filename |
| 33 | +(``.png``, ``.svg``, ``.eps``, ``.dxf``); without ``-o`` it defaults to |
| 34 | +``terminal`` for 2D formats when stdout is a TTY. Piped or redirected |
| 35 | +output without an explicit ``-t`` is rejected, to avoid dumping binary |
| 36 | +into the next tool by accident. |
| 37 | + |
| 38 | +GS1 Data Matrix from the shell |
| 39 | +------------------------------ |
| 40 | + |
| 41 | +GS1 Data Matrix uses ASCII with ``FNC1`` markers separating application |
| 42 | +identifiers and their values. ``--substitute-with-fnc1`` lets you build |
| 43 | +that input from a shell-friendly string: |
| 44 | + |
| 45 | +.. code-block:: console |
| 46 | +
|
| 47 | + $ pystrich datamatrix \ |
| 48 | + --text "|0105050070007664" \ |
| 49 | + --substitute-with-fnc1 "|" \ |
| 50 | + -o gs1.png |
| 51 | +
|
| 52 | +See :doc:`datamatrix` for the full encoding discussion. |
| 53 | + |
| 54 | +Limitations |
| 55 | +----------- |
| 56 | + |
| 57 | +The CLI doesn't expose every Python-API knob. Reach for the Python API for |
| 58 | +1D label fonts, custom borders, EAN-13's ``first_digit_y_offset``, or the |
| 59 | +deprecated DataMatrix ``compat`` encoding. |
| 60 | + |
| 61 | +API |
| 62 | +--- |
| 63 | + |
| 64 | +.. automodule:: pystrich.cli |
| 65 | + :members: main |
0 commit comments