Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
462 changes: 201 additions & 261 deletions docs/commands.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions openapi/api-geocoder/geocoding-v6.production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ paths:
access_token: YOUR_MAPBOX_ACCESS_TOKEN
x-mapbox-cli-command:
- geocoder
- forward-geocode
- forward
/search/geocode/v6/reverse:
get:
summary: Reverse geocoding
Expand Down Expand Up @@ -448,7 +448,7 @@ paths:
access_token: YOUR_MAPBOX_ACCESS_TOKEN
x-mapbox-cli-command:
- geocoder
- reverse-geocode
- reverse
/search/geocode/v6/batch:
post:
summary: Batch geocoding
Expand Down Expand Up @@ -670,7 +670,7 @@ paths:
access_token: YOUR_MAPBOX_ACCESS_TOKEN
x-mapbox-cli-command:
- geocoder
- batch-geocode
- batch
x-mapbox-restrictions-and-limits: |
To protect the Geocoding API and maximize service stability, Mapbox rate limits Geocoding API requests.

Expand Down
151 changes: 2 additions & 149 deletions openapi/api-gl/static-images.production.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,155 +107,8 @@ paths:
format: ''
access_token: YOUR_MAPBOX_ACCESS_TOKEN
x-mapbox-cli-command:
- static-images
- get-static-image
/styles/v1/{username}/{style_id}/static/{overlay}/auto/{width}x{height}{highRes}{format}:
get:
operationId: getStaticImageAuto
summary: Retrieve a static map image with auto-fit bounds
description: |
Render a static map image that automatically fits the viewport to the
bounding box of the provided overlay. The `auto` keyword replaces the
center, zoom, bearing and pitch segment, and the API calculates the
center and zoom needed to fit all overlay features within the image
dimensions.

Use the `padding` query parameter to inset the fitted view from the
image edges.

`bearing` and `pitch` cannot be combined with `auto`; supplying
coordinates alongside `auto` returns `422`. Combining `auto` with
`addlayer` or `setfilter` when there is no overlay also returns `422`,
as does a GeoJSON overlay that contains no features.
tags:
- Static Images
parameters:
- $ref: '#/components/parameters/username'
- $ref: '#/components/parameters/style_id'
- $ref: '#/components/parameters/overlay'
- $ref: '#/components/parameters/width'
- $ref: '#/components/parameters/height'
- $ref: '#/components/parameters/highRes'
- $ref: '#/components/parameters/format'
- $ref: '#/components/parameters/attribution'
- $ref: '#/components/parameters/logo'
- $ref: '#/components/parameters/before_layer'
- $ref: '#/components/parameters/padding'
- $ref: '#/components/parameters/addlayer'
- $ref: '#/components/parameters/setfilter'
- $ref: '#/components/parameters/layer_id'
- $ref: '#/components/parameters/accessToken'
responses:
'200':
$ref: '#/components/responses/ImageSuccess'
content:
image/png:
examples:
staticImageAuto:
summary: Static image auto-fit to a marker overlay
externalValue: https://api.mapbox.com/styles/v1/mapbox/streets-v12/static/pin-s+ff0000(-118.2437,34.0522)/auto/600x400@2x?access_token=MAPBOX_ACCESS_TOKEN
'304':
$ref: '#/components/responses/NotModified'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'422':
$ref: '#/components/responses/InvalidParameters'
'429':
$ref: '#/components/responses/RateLimitExceeded'
x-mapbox-docs-examples:
- example-id: staticImageAuto
title: Get a static map image auto-fit to a marker
request:
username: mapbox
style_id: streets-v12
overlay: pin-s+ff0000(-118.2437,34.0522)
width: 600
height: 400
highRes: '@2x'
format: ''
access_token: YOUR_MAPBOX_ACCESS_TOKEN
x-mapbox-cli-command:
- static-images
- get-static-image-auto
/styles/v1/{username}/{style_id}/static/{overlay}/{bbox}/{width}x{height}{highRes}{format}:
get:
operationId: getStaticImageBbox
summary: Retrieve a static map image for a bounding box
description: |
Render a static map image that fits a specified bounding box, given as
`[minlon,minlat,maxlon,maxlat]` in the path. The API calculates the
center and zoom needed to fit the bounding box within the image
dimensions.

Use the `padding` query parameter to inset the fitted view from the
image edges.

`bearing` and `pitch` cannot be combined with a bounding box; supplying
extra coordinates after the bounding box returns `422`.
tags:
- Static Images
parameters:
- $ref: '#/components/parameters/username'
- $ref: '#/components/parameters/style_id'
- $ref: '#/components/parameters/overlay'
- $ref: '#/components/parameters/bbox'
- $ref: '#/components/parameters/width'
- $ref: '#/components/parameters/height'
- $ref: '#/components/parameters/highRes'
- $ref: '#/components/parameters/format'
- $ref: '#/components/parameters/attribution'
- $ref: '#/components/parameters/logo'
- $ref: '#/components/parameters/before_layer'
- $ref: '#/components/parameters/padding'
- $ref: '#/components/parameters/addlayer'
- $ref: '#/components/parameters/setfilter'
- $ref: '#/components/parameters/layer_id'
- $ref: '#/components/parameters/accessToken'
responses:
'200':
$ref: '#/components/responses/ImageSuccess'
content:
image/png:
examples:
staticImageBbox:
summary: Static image fitted to a Washington DC bounding box
externalValue: https://api.mapbox.com/styles/v1/mapbox/streets-v12/static/pin-s+ff0000(-77.0353,38.8895)/[-77.043686,38.892035,-76.933086,38.942035]/600x400@2x?access_token=MAPBOX_ACCESS_TOKEN
'304':
$ref: '#/components/responses/NotModified'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'422':
$ref: '#/components/responses/InvalidParameters'
'429':
$ref: '#/components/responses/RateLimitExceeded'
x-mapbox-docs-examples:
- example-id: staticImageBbox
title: Get a static map image for a bounding box in Washington DC
request:
username: mapbox
style_id: streets-v12
overlay: pin-s+ff0000(-77.0353,38.8895)
bbox: '[-77.043686,38.892035,-76.933086,38.942035]'
width: 600
height: 400
highRes: '@2x'
format: ''
access_token: YOUR_MAPBOX_ACCESS_TOKEN
x-mapbox-cli-command:
- static-images
- get-static-image-bbox
- static
- get-image
components:
parameters:
username:
Expand Down
4 changes: 2 additions & 2 deletions openapi/api-gl/static-tiles.production.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ paths:
format: ''
access_token: YOUR_MAPBOX_ACCESS_TOKEN
x-mapbox-cli-command:
- static-tiles
- get-static-tile
- static
- get-tile
components:
parameters:
username:
Expand Down
4 changes: 2 additions & 2 deletions openapi/api-rasterarrays/rasterarrays.production.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ paths:
jobid: clnf3oau5005g08kzhr460vut
operationId: getMrtTile
x-mapbox-cli-command:
- rasterarrays
- get-mrt-tile
- tilesets
- get-mrt
components:
securitySchemes:
AccessTokenQuery:
Expand Down
2 changes: 1 addition & 1 deletion openapi/api-rastertiles/rastertiles.production.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ paths:
access_token: YOUR_MAPBOX_ACCESS_TOKEN
x-mapbox-cli-command:
- tilesets
- get-rastertile
- get-tile
components:
parameters:
tilesets:
Expand Down
4 changes: 2 additions & 2 deletions openapi/api-tilequery/tilequery.production.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ paths:
'500':
$ref: '#/components/responses/ErrorResponse'
x-mapbox-cli-command:
- tilequery
- get
- tilesets
- query
components:
securitySchemes:
AccessTokenQuery:
Expand Down
2 changes: 1 addition & 1 deletion openapi/api-vectortiles/vectortiles.production.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ paths:
access_token: YOUR_MAPBOX_ACCESS_TOKEN
x-mapbox-cli-command:
- tilesets
- get-vectortile
- get-mvt
components:
parameters:
tileset_id:
Expand Down
4 changes: 2 additions & 2 deletions src/generate_skills.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2038,8 +2038,8 @@ mod tests {
let image = schema
.commands
.iter()
.find(|entry| entry.name == "get-static-image")
.expect("get-static-image is a command");
.find(|entry| entry.name == "get-image")
.expect("get-image is a command");
let high_res = image
.arguments
.iter()
Expand Down
65 changes: 48 additions & 17 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,15 +806,44 @@ fn report_parse_result(err: clap::Error, raw_argv: &[std::ffi::OsString]) -> Exi
Remedy::default().with_action(help_for_missing_subcommand(message, raw_argv))
}
// Clap rejected the line for a reason of its own — a misspelled flag,
// a value that would not parse. There is no command that answers
// that, and inventing one would be worse than the message alone.
_ => Remedy::default(),
// a value that would not parse. There is usually no command that
// answers that, and inventing one would be worse than the message
// alone — but clap's own suggester sometimes already has the answer,
// and `-o text` shows it; carry it over rather than losing it here.
_ => match clap_tip(&rendered) {
Some(tip) => Remedy::default().with_fix(&tip),
None => Remedy::default(),
},
});

output::emit_error(mode, &error.into());
ExitCode::from(code)
}

/// The `tip: …` line clap's own suggester renders for an unrecognized
/// subcommand or flag, if there is one.
///
/// Clap's rendering is an error paragraph, a blank line, then usage and a
/// hint — but for a suggestion it inserts the tip as its own paragraph
/// between the error and the usage line, which is exactly the paragraph
/// `report_parse_result`'s `message` skips past. `-o text` gets it because
/// clap prints the whole rendering there; this is what lets `-o json` carry
/// the same answer instead of silently dropping it — the caller `-o json`
/// is for (a script, an agent) is the one a rename breaks without an alias.
fn clap_tip(rendered: &str) -> Option<String> {
let mut lines = rendered.lines().map(str::trim);
// The first paragraph is the error message; skip to its blank line.
for line in lines.by_ref() {
if line.is_empty() {
break;
}
}
// The next non-blank line is either the tip or, when there is none,
// the usage line — only the former is worth keeping.
let next = lines.find(|line| !line.is_empty())?;
next.strip_prefix("tip:").map(|tip| tip.trim().to_string())
}

/// The subcommand placeholder clap ends a usage line with when one is still
/// required. Nothing here sets `subcommand_value_name`, so this is clap's own
/// default spelling.
Expand Down Expand Up @@ -1194,11 +1223,21 @@ mod tests {

let positional = app.clone().try_get_matches_from([
"mapbox",
"tilequery",
"get",
"mapbox.mapbox-streets-v8",
"static",
"get-image",
"--username",
"mapbox",
"streets-v11",
"pin-s+f00(-74,40)",
"-74.0",
"40.7",
"12",
"0",
"0",
"600",
"400",
"",
"",
]);
assert!(
positional.is_ok(),
Expand All @@ -1209,7 +1248,7 @@ mod tests {
let flag_value = app.try_get_matches_from([
"mapbox",
"geocoder",
"reverse-geocode",
"reverse",
"--longitude",
"-74.0",
"--latitude",
Expand All @@ -1235,15 +1274,7 @@ mod tests {
for argv in [
["mapbox", "search", "category", "coffee", "--proximity"].as_slice(),
["mapbox", "search", "forward", "--q", "coffee", "--bbox"].as_slice(),
[
"mapbox",
"geocoder",
"forward-geocode",
"--q",
"x",
"--proximity",
]
.as_slice(),
["mapbox", "geocoder", "forward", "--q", "x", "--proximity"].as_slice(),
] {
let mut argv = argv.to_vec();
argv.push("-121.90662,37.42827");
Expand Down Expand Up @@ -1272,7 +1303,7 @@ mod tests {
"mapbox", "search", "forward", "--q", "x", "--types", "--limit",
]
.as_slice(),
["mapbox", "geocoder", "forward-geocode", "--q", "--limit"].as_slice(),
["mapbox", "geocoder", "forward", "--q", "--limit"].as_slice(),
] {
let matches = build_app(&specs).try_get_matches_from(argv);
assert!(
Expand Down
Loading
Loading