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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
# six-hour default before anyone hears about it. That is not hypothetical —
# a test that blocked on `accept()` with no deadline wedged the Windows leg
# for its full six hours, and the only reason it went unnoticed for a day
# is that every run on `main` was cancelled by the next push first.
# is that every run on `main` was canceled by the next push first.
#
# On all three rather than Windows alone: nobody here runs Windows as a
# daily driver, so CI is the only signal it has — but a Unix leg that
Expand Down Expand Up @@ -307,7 +307,7 @@ jobs:
"https://github.com/rustsec/rustsec/releases/download/cargo-audit%2Fv${AUDIT_VERSION}/${name}.tgz"
echo "${AUDIT_SHA256} /tmp/cargo-audit.tgz" | sha256sum -c -
# The archive has a versioned top-level directory and carries a
# README and two licences beside the binary; name the one file that
# README and two licenses beside the binary; name the one file that
# belongs on PATH.
tar xzf /tmp/cargo-audit.tgz -C "$HOME/.cargo/bin" \
--strip-components=1 "${name}/cargo-audit"
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ that may never merge. They are not releases and are not listed here.
`unsupported scheme socks5` in the message is the part that distinguishes
it from the network being down.

- `rand` moved from 0.8 to 0.10. No behaviour changes: the two places it is
- `rand` moved from 0.8 to 0.10. No behavior changes: the two places it is
used — the PKCE verifier and the OAuth `state` in `mapbox auth login` —
draw from `ThreadRng` before and after, which `rand` declares a CSPRNG, and
`thread_rng().gen()` becoming `random()` is a rename. Recorded because it
is the crate that generates those two values, so a login problem around
this release should be able to find it. Both are now covered by tests
against RFC 7636, which they were not before.

- Both installers now honour `MAPBOX_CLI_NO_TELEMETRY`, the name the binary
- Both installers now honor `MAPBOX_CLI_NO_TELEMETRY`, the name the binary
reads. They were left on the old `DISABLE_TELEMETRY` when the binary was
renamed, so neither name silenced both halves: the documented variable
stopped the CLI's markers but not the installer's, and the old one did the
Expand Down
12 changes: 11 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,19 @@ logged in.

Four rules the compiler holds rather than a reviewer, declared in
`Cargo.toml` with the reasoning beside each: no `unsafe`, no `println!`
(stdout belongs to `output::emit`, the single place `--output` is honoured),
(stdout belongs to `output::emit`, the single place `--output` is honored),
no `dbg!`, no `todo!`/`unimplemented!`.

Write American English: comments, documentation, commit messages, and every
string the CLI prints. `prose_is_american_english` in
`tests/source_guards.rs` reads the files and fails on the British spelling,
so this is a test rather than something a reviewer has to notice, and the
failure names the file and the line. It leaves two things alone on purpose.
Fenced code blocks, because sample output and captured API responses are
quoted rather than written, and rewriting a word inside one would make the
document misquote its source. And the `cancelled` error code, which is a
compatibility promise scripts may match on rather than a spelling.

## Where the commands come from

Commands are generated at build time from the OpenAPI specs in `openapi/`,
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ edition = "2021"
description = "A command-line interface for Mapbox APIs, with commands generated at build time from OpenAPI specs."
repository = "https://github.com/mapbox/cli"
# The file rather than an SPDX expression: LICENSE is Mapbox's own terms and
# not an OSI licence, so there is no identifier that says what it grants.
# not an OSI license, so there is no identifier that says what it grants.
license-file = "LICENSE"
# A rail against an accidental `cargo publish`, not a decision that it never
# could be reconsidered: crates.io is for crates anyone may use under an open
# licence, and a publish cannot be taken back.
# license, and a publish cannot be taken back.
publish = false
# The oldest Rust this crate compiles on, measured rather than aspirational:
# `CredentialLock` in src/auth.rs calls `File::lock`/`unlock`, stabilised in
Expand Down Expand Up @@ -46,7 +46,7 @@ unsafe_code = "deny"
[lints.clippy]
# The output contract, made mechanical. This repo's rule is: don't reintroduce a
# `println!` for a result — stdout belongs to `output::emit`, which is the
# single place `--output` is honoured and the single place a result is
# single place `--output` is honored and the single place a result is
# written. There are no violations today; this keeps it that way.
# `print_stderr` is deliberately *not* denied: warnings and progress go to
# stderr from a dozen places on purpose, several of them outside the output
Expand Down
12 changes: 6 additions & 6 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -1586,7 +1586,7 @@ mapbox sprites delete ckstyle00000000000000001a zz-clitest-1 --username user

The sprite index **after** the delete — the named icon is gone from it, and
everything else is still there. A 200 with the full layout, not a 204: the
absence of the icon is the only acknowledgement there is.
absence of the icon is the only acknowledgment there is.

<table>
<tr><th width="50%">Terminal — <code>-o text</code></th><th width="50%">Agent — <code>-o json</code></th></tr>
Expand Down Expand Up @@ -1723,7 +1723,7 @@ one, so a plain map image needs no overlay expression.

### `mapbox static get-image`

A map image centred on a point.
A map image centered on a point.

#### Parameters

Expand Down Expand Up @@ -2083,7 +2083,7 @@ mapbox styles delete ckstyle00000000000000003c --username user

A 204 carries no body. Rather than print nothing, the CLI confirms what
happened — nothing is asked beforehand, so the line after the fact is the
only acknowledgement there is.
only acknowledgment there is.

<table>
<tr><th width="50%">Terminal — <code>-o text</code></th><th width="50%">Agent — <code>-o json</code></th></tr>
Expand Down Expand Up @@ -2524,7 +2524,7 @@ security, style quality, geospatial operations and the mobile and web SDKs.
Twenty skills, each a directory of Markdown.

**Not the same as [`generate-skills`](#generate-skills)**, which is its
neighbour in `--help` and writes something else entirely: that one renders a
neighbor in `--help` and writes something else entirely: that one renders a
skill describing *this CLI's own commands*, from the specs compiled into the
binary. These are about using Mapbox; that one is about using `mapbox`. They
share the destination flags below and nothing else.
Expand Down Expand Up @@ -2834,7 +2834,7 @@ mapbox/mapbox-agent-skills@main.` and `"updated": []`.
### `mapbox agent-skills uninstall`

Removes installed skill directories. At least one `NAME` is required — an
empty list is not a licence to remove everything.
empty list is not a license to remove everything.

**This is the one subcommand that makes no request.** It works from what is on
disk, which also means it can remove a skill that has since been unpublished.
Expand Down Expand Up @@ -3476,7 +3476,7 @@ names the flag rather than offering a login that could not outrank it.
| `http_<status>` | The API answered non-2xx. Carries `status` and the response `body`. |
| `request_failed` | Transport failure — proxy, DNS, TLS. Never carries the URL, because the access token rides in its query string. |

The CLI honours `HTTPS_PROXY`, `HTTP_PROXY`, `ALL_PROXY` and `NO_PROXY`, and
The CLI honors `HTTPS_PROXY`, `HTTP_PROXY`, `ALL_PROXY` and `NO_PROXY`, and
needs no proxy configuration of its own. Two things that look like network
faults and are not:

Expand Down
6 changes: 3 additions & 3 deletions scripts/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# irm https://cli.mapbox.com/install.ps1 | iex
#
# This is the Windows half of scripts/install.sh, which is POSIX sh and stops
# with instructions when it recognises Git Bash, MSYS2 or Cygwin. The two are
# with instructions when it recognizes Git Bash, MSYS2 or Cygwin. The two are
# the same script in two languages: same environment variables, same order of
# operations, and the same things said about a checksum that does not match, an
# install directory that cannot be written, and a `mapbox` that came from
Expand Down Expand Up @@ -86,7 +86,7 @@
# because this value comes from the environment and ends up in a header.
$InstallSource = $env:MAPBOX_CLI_INSTALL_SOURCE

# The switch src/telemetry.rs honours for the CLI's own User-Agent, read
# The switch src/telemetry.rs honors for the CLI's own User-Agent, read
# here the same way, because someone who put it in a Dockerfile and then
# runs `irm ... | iex` in the same file has already said which way they
# want it. The product token above survives it - the equivalent of
Expand All @@ -95,7 +95,7 @@
#
# Two names, and only the binary dropped the old one.
# MAPBOX_CLI_NO_TELEMETRY is the documented switch; DISABLE_TELEMETRY is
# what it was called before, and this script still honours it. The rename
# what it was called before, and this script still honors it. The rename
# was announced as breaking for the binary; nothing announced it for the
# installers, which are fetched and run in one line with no release notes
# in front of the reader - and breaking an opt-out is the one change that
Expand Down
6 changes: 3 additions & 3 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ USER_AGENT='mapbox-cli-install/1'
# header.
INSTALL_SOURCE="${MAPBOX_CLI_INSTALL_SOURCE:-}"

# The switch `src/telemetry.rs` honours for the CLI's own User-Agent, read here
# The switch `src/telemetry.rs` honors for the CLI's own User-Agent, read here
# the same way, because someone who put it in a Dockerfile and then pipes this
# script into sh in the same file has already said which way they want it. The
# product token above is what survives it — the equivalent of
Expand All @@ -71,7 +71,7 @@ INSTALL_SOURCE="${MAPBOX_CLI_INSTALL_SOURCE:-}"
#
# **Two names, and only the binary dropped the old one.**
# `MAPBOX_CLI_NO_TELEMETRY` is the documented switch; `DISABLE_TELEMETRY` is
# what it was called before, and this script still honours it. The rename was
# what it was called before, and this script still honors it. The rename was
# announced as breaking for the binary, so a `DISABLE_TELEMETRY=1` there
# genuinely stopped working and the changelog says so. Nothing announced it for
# the installers — this file is fetched and run in one line, so a reader has no
Expand Down Expand Up @@ -625,7 +625,7 @@ install_tilesets() {
return 2
}

# Honour MAPBOX_TILESETS_CLI, the override the CLI itself respects: someone
# Honor MAPBOX_TILESETS_CLI, the override the CLI itself respects: someone
# who has pointed it at a particular executable has already made this
# decision, whether or not that executable is currently there.
if [ -n "${MAPBOX_TILESETS_CLI:-}" ]; then
Expand Down
8 changes: 4 additions & 4 deletions scripts/test-install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#
# ci.yml runs it under both, because that is the split install.ps1 has to cope
# with: 5.1 is what `powershell` opens on a stock Windows 11 and is where the
# TLS default, the progress bar and the stderr-is-an-error behaviour bite.
# TLS default, the progress bar and the stderr-is-an-error behavior bite.
#
# It also runs on macOS and Linux under pwsh, which is how it is developed -
# there is no Windows to hand. The cases that cannot mean anything there (the
Expand Down Expand Up @@ -486,7 +486,7 @@ try {
$tagged = @($logged | Where-Object { $_ -like '*src/onboardingscriptrm-rf' })
Expect-Equal '2' ([string]$logged.Count) 'made the two requests a run makes: the manifest and the archive'
Expect-Equal '2' ([string]$marked.Count) 'both name the installer and the triple'
Expect-Equal '2' ([string]$tagged.Count) 'both carry the source tag, sanitised for a header'
Expect-Equal '2' ([string]$tagged.Count) 'both carry the source tag, sanitized for a header'
Clear-Env 'MAPBOX_CLI_INSTALL_SOURCE'

Start-Case 'DISABLE_TELEMETRY keeps it down to the product token'
Expand Down Expand Up @@ -514,10 +514,10 @@ try {
Clear-Env 'DISABLE_TELEMETRY'
Clear-Env 'MAPBOX_CLI_INSTALL_SOURCE'

Start-Case 'MAPBOX_CLI_NO_TELEMETRY is honoured, and outranks the old name'
Start-Case 'MAPBOX_CLI_NO_TELEMETRY is honored, and outranks the old name'
New-CaseEnv 'telemetry-new-name'
$env:MAPBOX_CLI_INSTALL_SOURCE = 'dockerfile'
# The documented name, which the binary reads and this script honours too.
# The documented name, which the binary reads and this script honors too.
$env:MAPBOX_CLI_NO_TELEMETRY = '1'
[IO.File]::WriteAllText($RequestLog, '')
Invoke-Installer
Expand Down
8 changes: 4 additions & 4 deletions scripts/test-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ expect_says() { # command-output want label
# and `sha256` has to choose between entries rather than match the only one
# there. One of the decoys is the Windows `.zip`, sitting immediately after
# the entry being read: extensions are no longer uniform across targets, and
# the neighbour a greedy match would bleed into is the one that proves it does
# the neighbor a greedy match would bleed into is the one that proves it does
# not.
make_channel() { # dir version [bad-sha|broken]
channel_dir="$1"
Expand Down Expand Up @@ -658,15 +658,15 @@ expect_in_file "$CURL_LOG" "-A ${INSTALLER_UA} (${TARGET}" 'DISABLE_TELEMETRY=0
expect_in_file "$CURL_LOG" ' src/dockerfile' 'and the tag comes back with it'
unset MAPBOX_TEST_CURL_LOG DISABLE_TELEMETRY MAPBOX_CLI_INSTALL_SOURCE

start 'MAPBOX_CLI_NO_TELEMETRY is honoured, and outranks the old name'
start 'MAPBOX_CLI_NO_TELEMETRY is honored, and outranks the old name'
new_case_env telemetry-new-name
export MAPBOX_INSTALL_TILESETS=no
export MAPBOX_CLI_INSTALL_SOURCE=dockerfile
shim curl-recording curl
CURL_LOG="${CASE_DIR}/curl-args"
export MAPBOX_TEST_CURL_LOG="$CURL_LOG"

# The documented name, which the binary reads and this script honours too.
# The documented name, which the binary reads and this script honors too.
: >"$CURL_LOG"
export MAPBOX_CLI_NO_TELEMETRY=1
run_piped && status=0 || status=$?
Expand Down Expand Up @@ -1026,7 +1026,7 @@ expect_no_out 'is not installed' 'says nothing else about it'
expect_no_out 'Install it as well?' 'does not ask'
expect_no_out 'fake pipx' 'installs nothing'

start 'MAPBOX_TILESETS_CLI is honoured, set or broken'
start 'MAPBOX_TILESETS_CLI is honored, set or broken'
new_case_env tilesets-override
shim pipx
mkdir -p "${CASE_DIR}/opt"
Expand Down
6 changes: 3 additions & 3 deletions src/agent_skills.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! `mapbox agent-skills` — install the published Mapbox Agent Skills.
//!
//! Not to be confused with its neighbour. [`crate::generate_skills`] writes a
//! Not to be confused with its neighbor. [`crate::generate_skills`] writes a
//! skill describing *this CLI's own commands*, rendered from the specs
//! compiled into the binary. This command installs the *hand-written Mapbox
//! domain skills* — cartography, token security, iOS and Android patterns,
Expand Down Expand Up @@ -1210,7 +1210,7 @@ mod tests {
encoder.finish().expect("finish gzip")
}

const SKILL_MD: &[u8] = b"---\nname: mapbox-cartography\ndescription: Map design, colour and type. Use when styling.\n---\n\n# Cartography\n";
const SKILL_MD: &[u8] = b"---\nname: mapbox-cartography\ndescription: Map design, color and type. Use when styling.\n---\n\n# Cartography\n";

fn one_skill() -> Vec<u8> {
archive(&[
Expand Down Expand Up @@ -1252,7 +1252,7 @@ mod tests {
assert_eq!(skill.name, "mapbox-cartography");
assert_eq!(
skill.description.as_deref(),
Some("Map design, colour and type. Use when styling.")
Some("Map design, color and type. Use when styling.")
);

let paths: Vec<String> = skill
Expand Down
10 changes: 5 additions & 5 deletions src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ impl Identity<'_> {
Some("pk") => "public (pk)",
Some("sk") => "secret (sk)",
Some("tk") => "temporary (tk)",
_ => "unrecognised prefix",
_ => "unrecognized prefix",
};
match self.expires_at {
Some(exp) => format!("{usage}, expires {}", time_until(exp, now)),
Expand Down Expand Up @@ -1062,7 +1062,7 @@ fn rejected_token(
),
"TokenInvalid" => (
"token_invalid",
"Mapbox does not recognise the token it would be given.".to_string(),
"Mapbox does not recognize the token it would be given.".to_string(),
),
"TokenExpired" => (
"token_expired",
Expand Down Expand Up @@ -1190,7 +1190,7 @@ fn profile_name(profile: Option<&str>) -> &str {
/// token in order to report that it would spend the refresh token is the
/// exact mutation the flag exists to avoid — and it takes no
/// [`CredentialLock`] either, since it writes nothing there is anything to
/// serialise against.
/// serialize against.
///
/// A precondition the real command would fail on is still a failure here:
/// `refresh` with nothing stored reports what `force_refresh` reports rather
Expand Down Expand Up @@ -2195,7 +2195,7 @@ mod tests {
assert_eq!(token_usage("pk.body.signature"), Some("pk"));
assert_eq!(token_usage("sk.body.signature"), Some("sk"));
assert_eq!(token_usage("tk.body.signature"), Some("tk"));
// Anything else is reported as unrecognised rather than guessed at.
// Anything else is reported as unrecognized rather than guessed at.
assert_eq!(token_usage("xx.body.signature"), None);
assert_eq!(token_usage("pk."), None);
assert_eq!(token_usage("nodotsatall"), None);
Expand Down Expand Up @@ -2515,7 +2515,7 @@ mod tests {
);
assert!(
elapsed < Duration::from_secs(5),
"waited {elapsed:?}, so the deadline is not being honoured"
"waited {elapsed:?}, so the deadline is not being honored"
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub fn warn_output_ignored(matches: &ArgMatches) {
return;
}
eprintln!(
"Warning: `--{}` is not honoured by `{COMMAND}` — a completion script is a shell \
"Warning: `--{}` is not honored by `{COMMAND}` — a completion script is a shell \
script, and wrapping it in an envelope would leave it unsourceable.",
crate::output::ARG
);
Expand Down Expand Up @@ -155,7 +155,7 @@ pub fn run(app: &Command, matches: &ArgMatches) -> Result<()> {
// the result, and there is no rendering of it that is not itself.
let mut out = io::stdout().lock();
match out.write_all(&script).and_then(|()| out.flush()) {
// A reader that stopped reading is `head`'s ordinary behaviour, not a
// A reader that stopped reading is `head`'s ordinary behavior, not a
// failure to report: the error envelope would be the only thing left
// on a terminal after a command that did exactly what was asked.
Err(e) if e.kind() == io::ErrorKind::BrokenPipe => Ok(()),
Expand Down
2 changes: 1 addition & 1 deletion src/confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//! out unasked.
//!
//! `--yes` says the answer is yes before it is asked, which is the only way a
//! caller *at* a terminal can get the non-interactive behaviour on purpose.
//! caller *at* a terminal can get the non-interactive behavior on purpose.
//!
//! The question is deliberately not `--output`-aware. It goes to stderr as
//! prose in both modes, because the only way to see it is to be a person at a
Expand Down
4 changes: 2 additions & 2 deletions src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ fn is_binary_content_type(content_type: &str) -> bool {
///
/// Guessing from the content type rather than always saying `.png`: telling
/// someone to redirect a glyph range into `out.png` is advice that produces
/// a mislabelled file, and it reads as though the command misunderstood what
/// a mislabeled file, and it reads as though the command misunderstood what
/// it fetched.
fn suggested_extension(content_type: &str) -> &'static str {
let essence = content_type
Expand Down Expand Up @@ -1301,7 +1301,7 @@ fn suggested_extension(content_type: &str) -> &'static str {
}

/// Writes raw bytes to stdout, refusing to do so when that is a terminal —
/// `curl`'s behaviour, and for the same reason: a few hundred KB of PNG will
/// `curl`'s behavior, and for the same reason: a few hundred KB of PNG will
/// otherwise scramble the user's shell.
fn write_binary(body: &[u8], content_type: &str) -> Result<()> {
use std::io::{IsTerminal, Write};
Expand Down
Loading