B
    @\                 @   sv   d Z ddlmZmZmZmZ ddlZeeZ	ddl
Z
ddlmZ ddlmZ ddlmZ ddlmZ d	Zd
d ZdS )a   Provide a ``main`` function to run bokeh commands.

The following are equivalent:

* Running the ``bokeh`` command line script:

  .. code-block:: sh

      bokeh serve --show app.py

* Using ``python -m bokeh``:

  .. code-block:: sh

      python -m bokeh serve --show app.py

* Executing ``main`` programmatically:

  .. code-block:: python

      from bokeh.command.bootstrap import main

      main(["bokeh", "serve", "--show", "app.py"])

    )absolute_importdivisionprint_functionunicode_literalsN)__version__)	nice_join   )die)subcommands)mainc          
   C   s   t | dkr(tdtdd tjD   tj| d dd}|jdd	d
td |j	dd}x8tjD ].}|j
|j|jd}||d}|j|jd q`W || dd }y|| W n2 tk
r } ztdt|  W dd}~X Y nX dS )a   Execute the Bokeh command.

    Args:
        argv (seq[str]) : a list of command line arguments to process

    Returns:
        None

    The first item in ``argv`` is typically "bokeh", and the second should
    be the name of one of the available subcommands:

    * :ref:`html <bokeh.command.subcommands.html>`
    * :ref:`info <bokeh.command.subcommands.info>`
    * :ref:`json <bokeh.command.subcommands.json>`
    * :ref:`png <bokeh.command.subcommands.png>`
    * :ref:`sampledata <bokeh.command.subcommands.sampledata>`
    * :ref:`secret <bokeh.command.subcommands.secret>`
    * :ref:`serve <bokeh.command.subcommands.serve>`
    * :ref:`static <bokeh.command.subcommands.static>`
    * :ref:`svg <bokeh.command.subcommands.svg>`

    r   z*ERROR: Must specify subcommand, one of: %sc             s   s   | ]}|j V  qd S )N)name).0x r   6lib/python3.7/site-packages/bokeh/command/bootstrap.py	<genexpr>]   s    zmain.<locals>.<genexpr>r   z;See '<command> --help' to read about a specific subcommand.)progZepilogz-vz	--versionversion)actionr   zSub-commands)help)parser)invokeNzERROR: )lenr	   r   r
   allargparseArgumentParseradd_argumentr   Zadd_subparsersZ
add_parserr   r   Zset_defaultsr   
parse_args	Exceptionstr)argvr   ZsubsclsZ	subparserZ
subcommandargser   r   r   r   E   s     
r   )__doc__Z
__future__r   r   r   r   ZloggingZ	getLogger__name__logr   Zbokehr   Zbokeh.util.stringr   utilr	    r
   __all__r   r   r   r   r   <module>   s   
