mickael9 avatar mickael9 committed 2c01b99

Group search actions and add search similarity ratio option.

Comments (0)

Files changed (1)

             description="A command-line Ge.tt uploader and manager",
             epilog="Note that whenever http://ge.tt/<share_name>[/v/<fileid>] is expected, you can omit the http://ge.tt/ part.")
     parser.add_argument('-D', dest='debug', action='store_true', help='Debug API calls (warning: very verbose)')
-    # parser.add_argument('-R', '--similarity-ratio', default=DEFAULT_SIMILARITY_RATIO, type=float, dest='similarity_ratio', action='store_const', help='Similarity ratio (between 0 and 1) used for searching')
 
     upload_group = parser.add_argument_group('Upload options')
     upload_group.add_argument('file', nargs='*', type=pattern, help="Name of a file or a directory to upload. Patterns are allowed. This is not recursive.")
     upload_group.add_argument('-s', dest='share', help='URL of the share to upload to (defaults to a newly created one)')
     upload_group.add_argument('-P', dest='parallel_upload', action='store_true', help='Upload files in parallel rather than sequentially, the progress bars are displayed in ascending file size order')
 
+    search_group = parser.add_argument_group('Search actions')
+    search_group.add_argument('-S', '--search', nargs='+', dest='search', metavar='SEARCH_TERM', help='Search in share titles and file names.')
+    search_group.add_argument('-R', '--similarity-ratio', default=DEFAULT_SIMILARITY_RATIO, type=float, dest='similarity_ratio', help='Similarity ratio (between 0 and 1) used for searching')
+
     other_group = parser.add_argument_group('Other actions')
     other_group.add_argument('--delete', nargs='+', dest='delete', metavar='URL', help='Delete a share or a file')
     other_group.add_argument('-l', '--list', nargs='*', dest='list', metavar='SHARE_URL', help='List the files in the specified share. If no share is specified, list all your shares.')
-    other_group.add_argument('-S', '--search', nargs='+', dest='search', metavar='SEARCH_TERMS', help='Search in share titles and file names.')
 
     auth_group = parser.add_argument_group('Authentification')
     auth_group.add_argument('-L', dest='ignore_token', action='store_true', help='Log-in with a different account than the stored one (if any)')
         phrase_simple = simplify(phrase)
         print('Searching for `%s`...\n' % phrase)
 
-        # ratio = args.similarity_ratio
-        # if not 0 <= ratio <= 1:
-        #     ratio = DEFAULT_SIMILARITY_RATIO
-        #     print('Bad similarity ratio value. Using default: %2.f' % DEFAULT_SIMILARITY_RATIO)
-        ratio = DEFAULT_SIMILARITY_RATIO
+        ratio = args.similarity_ratio
+        if not 0 <= ratio <= 1:
+            ratio = DEFAULT_SIMILARITY_RATIO
+            logger.warning('Bad similarity ratio value. Using default: %2.f' % DEFAULT_SIMILARITY_RATIO)
+
         is_similar = lambda a, b: similar(a, b, ratio)
 
         found_in_shares = []
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.