3
_Af                 @   s2   d dl mZ d dlmZmZ G dd deeZdS )    )print_function)CommandMirrorSafeCommandc               @   s4   e Zd ZdZdZdZdZdd Zdd Zd	d
 Z	dS )ListTz.List projects and their associated directoriesz9
%prog [-f] [<project>...]
%prog [-f] -r str1 [str2]..."
z
List all projects; pass '.' to list the project for the cwd.

This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'.
c             C   sf   |j dddddd |j ddd	d
d |j dddddd |j dddddd |j dddddd d S )Nz-rz--regexregex
store_truezFFilter the project list based on regex or wildcard matching of strings)destactionhelpz-gz--groupsgroupsz=Filter the project list based on the groups the project is in)r   r
   z-fz
--fullpathfullpathz<Display the full work tree path instead of the relative pathz-nz--name-only	name_onlyz'Display only the name of the repositoryz-pz--path-only	path_onlyz'Display only the path of the repository)
add_option)selfp r   >/home/qytech/356xLinux510-101server/.repo/repo/subcmds/list.py_Options#   s    zList._Optionsc             C   s   |j r|jr| jjd d S )Nzcannot combine -f and -n)r   r   OptionParsererror)r   optargsr   r   r   ValidateOptions4   s    zList.ValidateOptionsc                s    j s| j| jd}n
| j|} fdd}g }xf|D ]^} jr\ j r\|jd|j  q8 jr~ j r~|jd||  q8|jd|||jf  q8W |j  t	dj
| dS )aH  List all projects and the associated directories.

    This may be possible to do with 'repo forall', but repo newbies have
    trouble figuring that out.  The idea here is that it should be more
    discoverable.

    Args:
      opt: The options.
      args: Positional args.  Can be a list of projects to list, or empty.
    )r   c                s    j r| jS | jS )N)r   worktreerelpath)x)r   r   r   _getpathH   s    zList.Execute.<locals>._getpathz%sz%s : %s
N)r   GetProjectsr   FindProjectsr   r   appendnamesortprintjoin)r   r   r   projectsr   linesprojectr   )r   r   Execute8   s    

zList.ExecuteN)
__name__
__module____qualname__commonhelpSummary	helpUsagehelpDescriptionr   r   r)   r   r   r   r   r      s   r   N)
__future__r   commandr   r   r   r   r   r   r   <module>   s   