B
    ãUvgË
  ã               @   s„   d Z ddlZddlZddlmZ ddlmZ ddlmZm	Z	 ddl
mZmZmZ ddlmZ ddlmZ d	d
gZdd	„ Zdd
„ ZdS )z=A single place for constructing and exposing the main parser
é    N)Ú__version__)Ú
cmdoptions)ÚConfigOptionParserÚUpdatingDefaultsHelpFormatter)Úcommands_dictÚget_similar_commandsÚget_summaries)ÚCommandError)Úget_progÚcreate_main_parserÚparse_commandc              C   s¨   ddt ƒ dtƒ dœ} tf | Ž}| ¡  tj tj tj t	¡dd¡¡}dt
|tjdd… f |_t tj|¡}| |¡ d	|_tƒ }d
gdd„ |D ƒ }d |¡|_|S )z6Creates and returns the main parser for pip's CLI
    z
%prog <command> [options]FÚglobal)ÚusageÚadd_help_optionÚ	formatterÚnameÚprogz..zpip %s from %s (python %s)Né   TÚ c             S   s   g | ]\}}d ||f ‘qS )z%-27s %s© )Ú.0ÚiÚjr   r   ú>/tmp/pip-install-r_9ig3yj/pip/pip/_internal/cli/main_parser.pyú
<listcomp>3   s    z&create_main_parser.<locals>.<listcomp>Ú
)r   r
   r   Údisable_interspersed_argsÚosÚpathÚabspathÚjoinÚdirnameÚ__file__r   ÚsysÚversionr   Úmake_option_groupÚgeneral_groupÚadd_option_groupÚmainr   Údescription)Ú	parser_kwÚparserÚpip_pkg_dirÚgen_optsÚcommand_summariesr)   r   r   r   r      s$    


c             C   sÊ   t ƒ }| | ¡\}}|jr>tj |j¡ tj tj¡ t ¡  |rZ|d dkrjt	|ƒdkrj| 
¡  t ¡  |d }|tkr¬t|ƒ}d| g}|rž| d| ¡ td |¡ƒ‚| d d … }| |¡ ||fS )Nr   Úhelpé   zunknown command "%s"zmaybe you meant "%s"z - )r   Ú
parse_argsr$   r#   ÚstdoutÚwriter   ÚlinesepÚexitÚlenÚ
print_helpr   r   Úappendr	   r    Úremove)Úargsr+   Úgeneral_optionsÚ	args_elseÚcmd_nameÚguessÚmsgÚcmd_argsr   r   r   r   9   s&    	

)Ú__doc__r   r#   Úpipr   Zpip._internal.clir   Úpip._internal.cli.parserr   r   Úpip._internal.commandsr   r   r   Úpip._internal.exceptionsr	   Úpip._internal.utils.miscr
   Ú__all__r   r   r   r   r   r   Ú<module>   s   $