mickael9 avatar mickael9 committed 19feec9

Allow share URLS in --list command and change some help messages

Comments (0)

Files changed (1)

 
     home = os.getenv('USERPROFILE') or os.getenv('HOME')
 
-    parser = argparse.ArgumentParser(description="A command-line Ge.tt uploader and manager")
+    parser = argparse.ArgumentParser(
+            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')
 
     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('-t', dest='title', help='Title of the share')
-    upload_group.add_argument('-s', dest='share', help='Name or URL of the share to upload to (defaults to a newly created one)')
+    upload_group.add_argument('-t', dest='title', help='Title of the newly created share')
+    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')
 
     other_group = parser.add_argument_group('Other actions')
-    other_group.add_argument('--delete', nargs='+', dest='delete', metavar='SHARE_OR_FILE', help='Delete a share or a file (url or path)')
-    other_group.add_argument('--list', nargs='*', dest='list', metavar='SHARE_NAME', help='List the files in the specified share. If no share is specified, list all your shares.')
+    other_group.add_argument('--delete', nargs='+', dest='delete', metavar='URL', help='Delete a share or a file')
+    other_group.add_argument('--list', nargs='*', dest='list', metavar='SHARE_URL', help='List the files in the specified share. If no share is specified, list all your shares.')
 
     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)')
 
     if args.list is not None:
         for name in args.list:
-            share = Share(name)
+            match = url_re.match(name)
+
+            if not match or match.group(2):
+                parser.error('argument --list: invalid format, please supply either share url or path')
+
+            share = Share(match.group(1))
             show_share(share)
 
         if not args.list:
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.