@@ -148,19 +148,35 @@ def __call__(url,
148148 return
149149
150150 if project is None :
151- from datalad .ui import ui
152151 projects = platform .get_project_ids ()
153- ui .message (
154- 'No project name specified. The following projects are '
155- 'available on {} for user {}:' .format (
152+ from datalad .ui import ui
153+ if ui .is_interactive :
154+ import inquirer
155+ from inquirer .themes import GreenPassion
156+ message = 'Select a project via arrow keys, ' \
157+ 'confirm with "Enter"' .format (
156158 url ,
157- 'anonymous' if platform .credential_name == 'anonymous'
158- else platform .authenticated_user ))
159- for p in sorted (projects ):
160- # list and prep for C&P
161- # TODO multi-column formatting?
162- ui .message (" {}" .format (quote_cmdlinearg (p )))
163- return
159+ 'anonymous' if platform .credential_name == 'anonymous' \
160+ else platform .authenticated_user )
161+ checkbox = [inquirer .List ('project' ,
162+ message = message ,
163+ choices = sorted (projects ))]
164+ resp = inquirer .prompt (checkbox , theme = GreenPassion ())
165+ lgr .info ("Received the following project selection from the "
166+ "interactive prompt: %s" , str (resp ['project' ]))
167+ project = resp ['project' ]
168+ else :
169+ ui .message (
170+ 'No project name specified. The following projects are '
171+ 'available on {} for user {}:' .format (
172+ url ,
173+ 'anonymous' if platform .credential_name == 'anonymous'
174+ else platform .authenticated_user ))
175+ for p in sorted (projects ):
176+ # list and prep for C&P
177+ # TODO multi-column formatting?
178+ ui .message (" {}" .format (quote_cmdlinearg (p )))
179+ return
164180
165181 # query the specified project to make sure it exists and is accessible
166182 try :
0 commit comments