Skip to content

Commit

Permalink
Stabilize cargo logout
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Apr 9, 2023
1 parent 1b2de21 commit 4b907f0
Show file tree
Hide file tree
Showing 20 changed files with 467 additions and 58 deletions.
5 changes: 0 additions & 5 deletions src/bin/cargo/commands/logout.rs
Expand Up @@ -10,11 +10,6 @@ pub fn cli() -> Command {
}

pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
if !config.cli_unstable().credential_process {
config
.cli_unstable()
.fail_if_stable_command(config, "logout", 8933)?;
}
ops::registry_logout(
config,
args.get_one::<String>("registry").map(String::as_str),
Expand Down
2 changes: 1 addition & 1 deletion src/doc/man/cargo-login.md
Expand Up @@ -48,4 +48,4 @@ Take care to keep the token secret, it should not be shared with anyone else.
cargo login

## SEE ALSO
{{man "cargo" 1}}, {{man "cargo-publish" 1}}
{{man "cargo" 1}}, {{man "cargo-logout" 1}}, {{man "cargo-publish" 1}}
55 changes: 55 additions & 0 deletions src/doc/man/cargo-logout.md
@@ -0,0 +1,55 @@
# cargo-logout(1)

## NAME

cargo-logout --- Remove an API token from the registry locally

## SYNOPSIS

`cargo logout` [_options_]

## DESCRIPTION

This command will remove the API token from the local credential storage.
Credentials are stored in `$CARGO_HOME/credentials.toml` where `$CARGO_HOME`
defaults to `.cargo` in your home directory.

If `--registry` is not specified, then the credentials for <https://crates.io/>
will be removed.

This will not revoke the token on the server. If you need to revoke the token,
visit the registry website and follow its instructions (see
<https://crates.io/me> to revoke the token for <https://crates.io/>).

## OPTIONS

### Logout Options

{{#options}}
{{> options-registry }}
{{/options}}

### Display Options

{{#options}}
{{> options-display }}
{{/options}}

{{> section-options-common }}

{{> section-environment }}

{{> section-exit-status }}

## EXAMPLES

1. Remove the default registry token:

cargo logout

2. Remove the token for a specific registry:

cargo logout --registry my-registry

## SEE ALSO
{{man "cargo" 1}}, {{man "cargo-login" 1}}
3 changes: 3 additions & 0 deletions src/doc/man/cargo.md
Expand Up @@ -102,6 +102,9 @@ available at <https://rust-lang.org>.
{{man "cargo-login" 1}}\
&nbsp;&nbsp;&nbsp;&nbsp;Save an API token from the registry locally.

{{man "cargo-logout" 1}}\
&nbsp;&nbsp;&nbsp;&nbsp;Remove an API token from the registry locally.

{{man "cargo-owner" 1}}\
&nbsp;&nbsp;&nbsp;&nbsp;Manage the owners of a crate on the registry.

Expand Down
2 changes: 1 addition & 1 deletion src/doc/man/generated_txt/cargo-login.txt
Expand Up @@ -100,5 +100,5 @@ EXAMPLES
cargo login

SEE ALSO
cargo(1), cargo-publish(1)
cargo(1), cargo-logout(1), cargo-publish(1)

106 changes: 106 additions & 0 deletions src/doc/man/generated_txt/cargo-logout.txt
@@ -0,0 +1,106 @@
CARGO-LOGOUT(1)

NAME
cargo-logout — Remove an API token from the registry locally

SYNOPSIS
cargo logout [options]

DESCRIPTION
This command will remove the API token from the local credential
storage. Credentials are stored in $CARGO_HOME/credentials.toml where
$CARGO_HOME defaults to .cargo in your home directory.

If --registry is not specified, then the credentials for
<https://crates.io/> will be removed.

This will not revoke the token on the server. If you need to revoke the
token, visit the registry website and follow its instructions (see
<https://crates.io/me> to revoke the token for <https://crates.io/>).

OPTIONS
Logout Options
--registry registry
Name of the registry to use. Registry names are defined in Cargo
config files
<https://doc.rust-lang.org/cargo/reference/config.html>. If not
specified, the default registry is used, which is defined by the
registry.default config key which defaults to crates-io.

Display Options
-v, --verbose
Use verbose output. May be specified twice for “very verbose”
output which includes extra output such as dependency warnings and
build script output. May also be specified with the term.verbose
config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:

o auto (default): Automatically detect if color support is
available on the terminal.

o always: Always display colors.

o never: Never display colors.

May also be specified with the term.color config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

Common Options
+toolchain
If Cargo has been installed with rustup, and the first argument to
cargo begins with +, it will be interpreted as a rustup toolchain
name (such as +stable or +nightly). See the rustup documentation
<https://rust-lang.github.io/rustup/overrides.html> for more
information about how toolchain overrides work.

--config KEY=VALUE or PATH
Overrides a Cargo configuration value. The argument should be in
TOML syntax of KEY=VALUE, or provided as a path to an extra
configuration file. This flag may be specified multiple times. See
the command-line overrides section
<https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides>
for more information.

-C PATH
Changes the current working directory before executing any specified
operations. This affects things like where cargo looks by default
for the project manifest (Cargo.toml), as well as the directories
searched for discovering .cargo/config.toml, for example.

-h, --help
Prints help information.

-Z flag
Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
details.

ENVIRONMENT
See the reference
<https://doc.rust-lang.org/cargo/reference/environment-variables.html>
for details on environment variables that Cargo reads.

EXIT STATUS
o 0: Cargo succeeded.

o 101: Cargo failed to complete.

EXAMPLES
1. Remove the default registry token:

cargo logout

2. Remove the token for a specific registry:

cargo logout --registry my-registry

SEE ALSO
cargo(1), cargo-login(1)

3 changes: 3 additions & 0 deletions src/doc/man/generated_txt/cargo.txt
Expand Up @@ -95,6 +95,9 @@ COMMANDS
cargo-login(1)
    Save an API token from the registry locally.

cargo-logout(1)
    Remove an API token from the registry locally.

cargo-owner(1)
    Manage the owners of a crate on the registry.

Expand Down
1 change: 1 addition & 0 deletions src/doc/src/SUMMARY.md
Expand Up @@ -82,6 +82,7 @@
* [cargo uninstall](commands/cargo-uninstall.md)
* [Publishing Commands](commands/publishing-commands.md)
* [cargo login](commands/cargo-login.md)
* [cargo logout](commands/cargo-logout.md)
* [cargo owner](commands/cargo-owner.md)
* [cargo package](commands/cargo-package.md)
* [cargo publish](commands/cargo-publish.md)
Expand Down
2 changes: 1 addition & 1 deletion src/doc/src/commands/cargo-login.md
Expand Up @@ -122,4 +122,4 @@ details on environment variables that Cargo reads.
cargo login

## SEE ALSO
[cargo(1)](cargo.html), [cargo-publish(1)](cargo-publish.html)
[cargo(1)](cargo.html), [cargo-logout(1)](cargo-logout.html), [cargo-publish(1)](cargo-publish.html)
129 changes: 129 additions & 0 deletions src/doc/src/commands/cargo-logout.md
@@ -0,0 +1,129 @@
# cargo-logout(1)

## NAME

cargo-logout --- Remove an API token from the registry locally

## SYNOPSIS

`cargo logout` [_options_]

## DESCRIPTION

This command will remove the API token from the local credential storage.
Credentials are stored in `$CARGO_HOME/credentials.toml` where `$CARGO_HOME`
defaults to `.cargo` in your home directory.

If `--registry` is not specified, then the credentials for <https://crates.io/>
will be removed.

This will not revoke the token on the server. If you need to revoke the token,
visit the registry website and follow its instructions (see
<https://crates.io/me> to revoke the token for <https://crates.io/>).

## OPTIONS

### Logout Options

<dl>
<dt class="option-term" id="option-cargo-logout---registry"><a class="option-anchor" href="#option-cargo-logout---registry"></a><code>--registry</code> <em>registry</em></dt>
<dd class="option-desc">Name of the registry to use. Registry names are defined in <a href="../reference/config.html">Cargo config
files</a>. If not specified, the default registry is used,
which is defined by the <code>registry.default</code> config key which defaults to
<code>crates-io</code>.</dd>


</dl>

### Display Options

<dl>
<dt class="option-term" id="option-cargo-logout--v"><a class="option-anchor" href="#option-cargo-logout--v"></a><code>-v</code></dt>
<dt class="option-term" id="option-cargo-logout---verbose"><a class="option-anchor" href="#option-cargo-logout---verbose"></a><code>--verbose</code></dt>
<dd class="option-desc">Use verbose output. May be specified twice for “very verbose” output which
includes extra output such as dependency warnings and build script output.
May also be specified with the <code>term.verbose</code>
<a href="../reference/config.html">config value</a>.</dd>


<dt class="option-term" id="option-cargo-logout--q"><a class="option-anchor" href="#option-cargo-logout--q"></a><code>-q</code></dt>
<dt class="option-term" id="option-cargo-logout---quiet"><a class="option-anchor" href="#option-cargo-logout---quiet"></a><code>--quiet</code></dt>
<dd class="option-desc">Do not print cargo log messages.
May also be specified with the <code>term.quiet</code>
<a href="../reference/config.html">config value</a>.</dd>


<dt class="option-term" id="option-cargo-logout---color"><a class="option-anchor" href="#option-cargo-logout---color"></a><code>--color</code> <em>when</em></dt>
<dd class="option-desc">Control when colored output is used. Valid values:</p>
<ul>
<li><code>auto</code> (default): Automatically detect if color support is available on the
terminal.</li>
<li><code>always</code>: Always display colors.</li>
<li><code>never</code>: Never display colors.</li>
</ul>
<p>May also be specified with the <code>term.color</code>
<a href="../reference/config.html">config value</a>.</dd>


</dl>

### Common Options

<dl>

<dt class="option-term" id="option-cargo-logout-+toolchain"><a class="option-anchor" href="#option-cargo-logout-+toolchain"></a><code>+</code><em>toolchain</em></dt>
<dd class="option-desc">If Cargo has been installed with rustup, and the first argument to <code>cargo</code>
begins with <code>+</code>, it will be interpreted as a rustup toolchain name (such
as <code>+stable</code> or <code>+nightly</code>).
See the <a href="https://rust-lang.github.io/rustup/overrides.html">rustup documentation</a>
for more information about how toolchain overrides work.</dd>


<dt class="option-term" id="option-cargo-logout---config"><a class="option-anchor" href="#option-cargo-logout---config"></a><code>--config</code> <em>KEY=VALUE</em> or <em>PATH</em></dt>
<dd class="option-desc">Overrides a Cargo configuration value. The argument should be in TOML syntax of <code>KEY=VALUE</code>,
or provided as a path to an extra configuration file. This flag may be specified multiple times.
See the <a href="../reference/config.html#command-line-overrides">command-line overrides section</a> for more information.</dd>


<dt class="option-term" id="option-cargo-logout--C"><a class="option-anchor" href="#option-cargo-logout--C"></a><code>-C</code> <em>PATH</em></dt>
<dd class="option-desc">Changes the current working directory before executing any specified operations. This affects
things like where cargo looks by default for the project manifest (<code>Cargo.toml</code>), as well as
the directories searched for discovering <code>.cargo/config.toml</code>, for example.</dd>


<dt class="option-term" id="option-cargo-logout--h"><a class="option-anchor" href="#option-cargo-logout--h"></a><code>-h</code></dt>
<dt class="option-term" id="option-cargo-logout---help"><a class="option-anchor" href="#option-cargo-logout---help"></a><code>--help</code></dt>
<dd class="option-desc">Prints help information.</dd>


<dt class="option-term" id="option-cargo-logout--Z"><a class="option-anchor" href="#option-cargo-logout--Z"></a><code>-Z</code> <em>flag</em></dt>
<dd class="option-desc">Unstable (nightly-only) flags to Cargo. Run <code>cargo -Z help</code> for details.</dd>


</dl>


## ENVIRONMENT

See [the reference](../reference/environment-variables.html) for
details on environment variables that Cargo reads.


## EXIT STATUS

* `0`: Cargo succeeded.
* `101`: Cargo failed to complete.


## EXAMPLES

1. Remove the default registry token:

cargo logout

2. Remove the token for a specific registry:

cargo logout --registry my-registry

## SEE ALSO
[cargo(1)](cargo.html), [cargo-login(1)](cargo-login.html)
3 changes: 3 additions & 0 deletions src/doc/src/commands/cargo.md
Expand Up @@ -102,6 +102,9 @@ available at <https://rust-lang.org>.
[cargo-login(1)](cargo-login.html)\
&nbsp;&nbsp;&nbsp;&nbsp;Save an API token from the registry locally.

[cargo-logout(1)](cargo-logout.html)\
&nbsp;&nbsp;&nbsp;&nbsp;Remove an API token from the registry locally.

[cargo-owner(1)](cargo-owner.html)\
&nbsp;&nbsp;&nbsp;&nbsp;Manage the owners of a crate on the registry.

Expand Down
1 change: 1 addition & 0 deletions src/doc/src/commands/publishing-commands.md
@@ -1,5 +1,6 @@
# Publishing Commands
* [cargo login](cargo-login.md)
* [cargo logout](cargo-logout.md)
* [cargo owner](cargo-owner.md)
* [cargo package](cargo-package.md)
* [cargo publish](cargo-publish.md)
Expand Down
3 changes: 2 additions & 1 deletion src/doc/src/reference/config.md
Expand Up @@ -296,7 +296,7 @@ Cargo will search `PATH` for its executable.

Configuration values with sensitive information are stored in the
`$CARGO_HOME/credentials.toml` file. This file is automatically created and updated
by [`cargo login`]. It follows the same format as Cargo config files.
by [`cargo login`] and [`cargo logout`]. It follows the same format as Cargo config files.

```toml
[registry]
Expand Down Expand Up @@ -1193,6 +1193,7 @@ Sets the width for progress bar.

[`cargo bench`]: ../commands/cargo-bench.md
[`cargo login`]: ../commands/cargo-login.md
[`cargo logout`]: ../commands/cargo-logout.md
[`cargo doc`]: ../commands/cargo-doc.md
[`cargo new`]: ../commands/cargo-new.md
[`cargo publish`]: ../commands/cargo-publish.md
Expand Down

0 comments on commit 4b907f0

Please sign in to comment.