U
    /e|                     @  s   d Z ddlmZ ddlZeeZddl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d	lmZ dd
lmZ dZddd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"])

    )annotationsN)Sequence)__version__)settings)	nice_join   )subcommands)die)mainzSequence[str]None)argvreturnc           	   
   C  s0  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}tjD ].}|j
|j|jd}||d}|j|jd q^|| dd }z||}W n< tk
r } ztjrʂ ntdt|  W 5 d}~X Y nX |dkrtd n*|dk	r,t|tr,|dkr,t| dS )aW   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:`info <bokeh.command.subcommands.info>`
    * :ref:`json <bokeh.command.subcommands.json>`
    * :ref:`sampledata <bokeh.command.subcommands.sampledata>`
    * :ref:`secret <bokeh.command.subcommands.secret>`
    * :ref:`serve <bokeh.command.subcommands.serve>`
    * :ref:`static <bokeh.command.subcommands.static>`

    r   z*ERROR: Must specify subcommand, one of: %sc                 S  s   g | ]
}|j qS  )name).0xr   r   ;/tmp/pip-unpacked-wheel-f5fndrjf/bokeh/command/bootstrap.py
<listcomp>\   s     zmain.<locals>.<listcomp>r   z;See '<command> --help' to read about a specific subcommand.)progepilogz-vz	--versionversion)actionr   zSub-commands)help)parser)invokeNzERROR: FT)lenr	   r   r   allargparseArgumentParseradd_argumentr   add_subparsers
add_parserr   r   set_defaultsr   
parse_args	Exceptionr   devstrsysexit
isinstanceint)	r   r   subsclsZ	subparser
subcommandargsreter   r   r   r
   G   s.    

"
 r
   )__doc__
__future__r   logging	getLogger__name__logr   r'   typingr   Zbokehr   Zbokeh.settingsr   Zbokeh.util.stringr    r   utilr	   __all__r
   r   r   r   r   <module>   s   
