3 个不稳定版本
| 0.2.1 | 2022年5月17日 |
|---|---|
| 0.2.0 | 2022年5月7日 |
| 0.1.0 | 2022年4月22日 |
680 在 Cargo 插件 中
22KB
443 行(不含注释)
Cargo-User
安装
安装 Cargo 后,以下命令将自动从 crates.io 构建 并安装 cargo-user
cargo install cargo-user
只要 $HOME/.cargo/bin/ 包含在 $PATH 中,子命令应立即可用。
用法
假设您已经运行了 cargo login,您应该首先运行 cargo user save 将您的凭证保存为配置文件。然后,您可以使用 cargo logout 或 cargo user clear 清除凭证,使用不同的凭证重新登录,并将这些凭证也保存起来。
cargo user save first
# Saved profile "first".
cargo user clear
# Cleared Cargo credentials.
cargo login
# [...]
cargo user save second
# Saved profile "second".
然后,您可以调用 cargo user current 打印当前加载的配置文件名称,cargo user list 查看所有可用的配置文件,以及 cargo user load 切换到另一个配置文件。
cargo user list
# first
# second
cargo user current
# second
cargo user load first
# Loaded profile "first".
cargo user current
# first
可以通过 cargo help user 或 cargo user --help 查看功能列表的完整列表。
详细信息
用于发布到 crates.io 的用户凭据保存在 $CARGO_HOME/credentials 中。此插件会保存该文件的副本,并以用户指定的名称作为凭据“配置文件”,保存在 $XDG_CONFIG_HOME/cargo-user/profiles/ 中。
例如,一个名为“third”的配置文件,使用 cargo user save third 保存,将保存在 $XDG_CONFIG_HOME/cargo-user/profiles/credentials-third。当稍后使用 cargo user load third 加载此配置文件时,该文件将复制回 $CARGO_HOME/credentials,并且立即可以通过 cargo publish 进行读取。
可以使用 cargo user find 打印保存配置文件目录的确切路径或特定配置文件的路径。
依赖项
~3.5MB
~64K SLoC