Anonymous avatar Anonymous committed 319dd30

extended paste.script.command.Command.challenge to ask for multiple options
returned as a list of lines

Comments (0)

Files changed (2)

paste/script/command.py

                 return response[0].lower() == 'y'
             print 'Y or N please'
 
-    def challenge(self, prompt, default=NoDefault, should_echo=True):
+    def challenge(self, prompt, default=NoDefault, should_echo=True, multi=False):
         """
         Prompt the user for a variable.
+        
+        in multi-mode, default will be ignored
         """
+        responses = []
         if default is not NoDefault:
             prompt += ' [%r]' % default
         prompt += ': '
+        first = True
         while 1:
             if should_echo:
                 prompt_method = raw_input
             else:
                 prompt_method = getpass.getpass
-            response = prompt_method(prompt).strip()
+            
+            if first:    
+                response = prompt_method(prompt).strip()
+                first = False
+            else:
+                response = prompt_method(' '*len(prompt)).strip()
             if not response:
-                if default is not NoDefault:
+                if default is not NoDefault and not multi:
                     return default
                 else:
-                    continue
+                    return responses
             else:
-                return response
+                if multi:
+                    responses.append(response)
+                else:
+                    return response
         
     def pad(self, s, length, dir='left'):
         if len(s) >= length:
       "Framework :: Paste",
       ],
     keywords='web wsgi setuptools framework command-line setup',
-    author="Ian Bicking",
-    author_email="ianb@colorstudy.com",
+    author="Ian Bicking, Matthias Felsche",
+    author_email="ianb@colorstudy.com, mfelsche@net",
     url="http://pythonpaste.org/script/",
     namespace_packages=['paste'],
     license='MIT',
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.