
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/plot_e05_naming.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_auto_examples_plot_e05_naming.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_plot_e05_naming.py:


Naming
======

This module explains how naming rules can be applied to a CLI.

.. GENERATED FROM PYTHON SOURCE LINES 7-11

.. code-block:: Python


    from npdoc_cli import cli









.. GENERATED FROM PYTHON SOURCE LINES 12-18

Dashes and Underscores
----------------------
It's common for CLI to use dashes to seperate words when naming variables
in the terminal, however Python obviously won't support that. 
By default, ``cli.build()`` will turn replace underscores in program, command
subcommand and argument names. You can turn this off in the build call.

.. GENERATED FROM PYTHON SOURCE LINES 18-41

.. code-block:: Python


    @cli.program
    def prog_name(my_arg: int, my_option: float = 0):
        """
        Summary.

        Parameters
        ----------
        my_arg : int
            DESCRIPTION.
        my_option : float,optional
            DESCRIPTION
        """
        pass

    print('-- replace underscores --')
    cli.build()
    cli.print_help()

    print('-- keep underscores --')
    cli.build(replace_underscores=False)
    cli.print_help()





.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    -- replace underscores --
    usage: prog-name [-h] [-m MY_OPTION] my-arg {goodbye,hello} ...

    Summary.

    positional arguments:
      my-arg                DESCRIPTION.
      {goodbye,hello}       command help

    options:
      -h, --help            show this help message and exit
      -m MY_OPTION, --my-option MY_OPTION
                            DESCRIPTION
    -- keep underscores --
    usage: prog_name [-h] [-m MY_OPTION] my_arg {goodbye,hello} ...

    Summary.

    positional arguments:
      my_arg                DESCRIPTION.
      {goodbye,hello}       command help

    options:
      -h, --help            show this help message and exit
      -m MY_OPTION, --my_option MY_OPTION
                            DESCRIPTION




.. GENERATED FROM PYTHON SOURCE LINES 42-52

Short Flags
-----------
All keyword arguments are assigned a short flag and a long flag as
optional arguments in the CLI. Long
flags will always be the python arguments name as it exists in python + whatever
naming rules are applied to the build call. However, the short flag will
use the first letter of the argument's name. If another argument exists with
that flag, it will keep adding letters until a unique short flag is created.
In that respect, the order of arguments in the function signature will
determine the short flag if arguments have similar names.

.. GENERATED FROM PYTHON SOURCE LINES 52-70

.. code-block:: Python


    cli.reset()
    @cli.program
    def prog_name(option1: int = 0, option2: float = 0):
        """
        Summary.

        Parameters
        ----------
        option1 : int
            DESCRIPTION.
        option2 : float,optional
            DESCRIPTION
        """
        pass

    cli.build()
    cli.print_help()




.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    usage: prog-name [-h] [-o OPTION1] [-op OPTION2]

    Summary.

    options:
      -h, --help            show this help message and exit
      -o OPTION1, --option1 OPTION1
                            DESCRIPTION.
      -op OPTION2, --option2 OPTION2
                            DESCRIPTION





.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 0.004 seconds)


.. _sphx_glr_download_auto_examples_plot_e05_naming.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: plot_e05_naming.ipynb <plot_e05_naming.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: plot_e05_naming.py <plot_e05_naming.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: plot_e05_naming.zip <plot_e05_naming.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
