Repository: planetlabs/planet-client-python
Pull request #457 (2022-04-28 18:06:22)

Upload download order interface #365


Patch:
diff --git a/planet/cli/orders.py b/planet/cli/orders.py
index e1da200..764530b 100644
--- a/planet/cli/orders.py
+++ b/planet/cli/orders.py
@@ -179,24 +179,23 @@ async def wait(ctx, order_id, delay, max_attempts, state):
 @translate_exceptions
 @coro
 @click.argument('order_id', type=click.UUID)
-@click.option('-o',
-              '--overwrite',
-              is_flag=True,
-              default=False,
-              help=('Overwrite files if they already exist.'))
-@click.option('--dest',
+@click.option('--directory',
               default='.',
-              help=('Directory to download files to.'),
+              help=('Base directory for file download.'),
               type=click.Path(exists=True,
                               resolve_path=True,
                               writable=True,
                               file_okay=False))
-async def download(ctx, order_id, overwrite, dest):
+@click.option('--overwrite',
+              is_flag=True,
+              default=False,
+              help=('Overwrite files if they already exist.'))
+async def download(ctx, order_id, overwrite, directory):
     """Download order by order ID."""
     quiet = ctx.obj['QUIET']
     async with orders_client(ctx) as cl:
         await cl.download_order(str(order_id),
-                                directory=dest,
+                                directory=directory,
                                 overwrite=overwrite,
                                 progress_bar=not quiet)
 
diff --git a/planet/clients/orders.py b/planet/clients/orders.py
index 82da519..311711f 100644
--- a/planet/clients/orders.py
+++ b/planet/clients/orders.py
@@ -251,7 +251,7 @@ class OrdersClient():
         Parameters:
             location: Download location url including download token.
             filename: Custom name to assign to downloaded file.
-            directory: Write to given directory instead of current directory.
+            directory: Base directory for file download.
             overwrite: Overwrite any existing files.
             progress_bar: Show progress bar during download.
 
@@ -280,8 +280,8 @@ class OrdersClient():
 
         Parameters:
             order_id: The ID of the order
-            directory: Write to given directory instead of current directory.
-            overwrite: Overwrite any existing files.
+            directory: Root directory for file download.
+            overwrite: Overwrite files if they already exist.
             progress_bar: Show progress bar during download.
 
         Returns:


Test patch:
diff --git a/tests/integration/test_orders_cli.py b/tests/integration/test_orders_cli.py
index 4faa4dd..4f2c732 100644
--- a/tests/integration/test_orders_cli.py
+++ b/tests/integration/test_orders_cli.py
@@ -299,7 +299,8 @@ def test_cli_orders_download_dest(invoke, mock_download_response, oid):
     with runner.isolated_filesystem() as folder:
         dest_dir = Path(folder) / 'foobar'
         dest_dir.mkdir()
-        result = invoke(['download', '--dest', 'foobar', oid], runner=runner)
+        result = invoke(['download', '--directory', 'foobar', oid],
+                        runner=runner)
         assert not result.exception
 
         # Check that the files were downloaded to the custom directory