Case Study: cargo publish --help

Explaining several flags from the --help output from cargo publish subcommand may help further clarify:

$ cargo publish --help
cargo-publish 
Upload a package to the registry

USAGE:
    cargo publish [OPTIONS]

OPTIONS:
        --token <TOKEN>             Token to use when uploading
        --index <INDEX>             Registry index URL to upload the package to
        --registry <REGISTRY>       Registry to publish to
        # ...

--token is an authentication token, used to identify your request to the registry server (via the "authorization" header, generally speaking, or the "user-agent" header, using the temporary Shipyard.rs solution.

--index is the url of a git repository with metadata about the crates and crate versions available at the registry server.

--registry is the name of the registry server, specified to cargo via configuration. Specifically, the [registries] setting allows one to associate a registry name with an git url (i.e. what you might otherwise pass using the --index flag):

[registries.my-registry-server]
index = "https://git.shipyard.rs/my-registry-server/crate-index.git"

With this configuration, the registry name, passed via --registry flag, allows cargo to identify the crate --index git url for use in retrieving metadata about the registry server.