Skip to content

Commit 13aeb93

Browse files
authored
Merge pull request #185 from planetlabs/cli-limits-183-184
Document cli limit variable
2 parents 4bdf80f + a9ae48e commit 13aeb93

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

docs/source/cli/examples.rst

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
Examples
44
========
55

6+
Data Examples
7+
-------------
8+
69
Get the latest 10 items from the API of any ItemType::
710

811
planet data search --limit 10

planet/scripts/opts.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@
3939

4040

4141
def limit_option(default):
42+
limit_msg = "Limit the number of items. Default: {}".format(default)
4243
return click.option('--limit', default=default, required=False,
43-
type=num_type, help="Limit the number of items.")
44+
type=num_type, help=limit_msg)
4445

4546

4647
geom_filter = click.option('--geom', type=GeomFilter(), help=(

planet/scripts/v1.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
.replace('``', '\''))
5757
for k, v in metavar_docs.items()])
5858

59+
DEFAULT_SEARCH_LIMIT = 100
60+
MAX_PAGE_SIZE = 250
61+
5962

6063
@cli.group('data')
6164
def data():
@@ -77,15 +80,15 @@ def filter_dump(**kw):
7780

7881

7982
@data.command('search', epilog=filter_opts_epilog)
80-
@limit_option(100)
83+
@limit_option(DEFAULT_SEARCH_LIMIT)
8184
@pretty
8285
@asset_type_perms
8386
@search_request_opts
8487
def quick_search(limit, pretty, sort, **kw):
8588
'''Execute a quick search.'''
8689
req = search_req_from_opts(**kw)
8790
cl = clientv1()
88-
page_size = min(limit, 250)
91+
page_size = min(limit, MAX_PAGE_SIZE)
8992
echo_json_response(call_and_wrap(
9093
cl.quick_search, req, page_size=page_size, sort=sort
9194
), pretty, limit)
@@ -107,12 +110,12 @@ def create_search(pretty, **kw):
107110
@click.argument('search_id', default='@-', required=False)
108111
@sort_order
109112
@pretty
110-
@limit_option(100)
113+
@limit_option(DEFAULT_SEARCH_LIMIT)
111114
def saved_search(search_id, sort, pretty, limit):
112115
'''Execute a saved search'''
113116
sid = read(search_id)
114117
cl = clientv1()
115-
page_size = min(limit, 250)
118+
page_size = min(limit, MAX_PAGE_SIZE)
116119
echo_json_response(call_and_wrap(
117120
cl.saved_search, sid, page_size=page_size, sort=sort
118121
), limit=limit, pretty=pretty)
@@ -174,7 +177,7 @@ def download(asset_type, dest, limit, sort, search_id, dry_run, activate_only,
174177
quiet, **kw):
175178
'''Activate and download'''
176179
cl = clientv1()
177-
page_size = min(limit or 250, 250)
180+
page_size = min(limit or MAX_PAGE_SIZE, MAX_PAGE_SIZE)
178181
asset_type = list(chain.from_iterable(asset_type))
179182
# even though we're using functionality from click.Path, this was needed
180183
# to detect inability to write on Windows in a read-only vagrant mount...

0 commit comments

Comments
 (0)