Skip to content

Commit bf304aa

Browse files
committed
modify the code by comments
1 parent 13fccb2 commit bf304aa

File tree

9 files changed

+71
-65
lines changed

9 files changed

+71
-65
lines changed

Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ cargo-test-macro = { path = "crates/cargo-test-macro" }
3131
cargo-test-support = { path = "crates/cargo-test-support" }
3232
cargo-util = { version = "0.2.6", path = "crates/cargo-util" }
3333
cargo_metadata = "0.18.1"
34-
clap = "4.4.7"
34+
clap = "4.4.11"
3535
color-print = "0.3.5"
3636
core-foundation = { version = "0.9.3", features = ["mac_os_10_7_support"] }
3737
crates-io = { version = "0.39.0", path = "crates/crates-io" }

src/bin/cargo/commands/owner.rs

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,10 @@ use cargo_credential::Secret;
66
pub fn cli() -> Command {
77
subcommand("owner")
88
.about("Manage the owners of a crate on the registry")
9-
.arg(Arg::new("crate").hide(true))
109
.arg_required_else_help(true)
1110
.args_conflicts_with_subcommands(true)
12-
.override_usage(
13-
"\
14-
cargo[EXE] owner add <OWNER_NAME> [CRATE_NAME] [OPTIONS]
15-
cargo[EXE] owner remove <OWNER_NAME> [CRATE_NAME] [OPTIONS]
16-
cargo[EXE] owner list [CRATE_NAME] [OPTIONS]",
17-
)
11+
.flatten_help(true)
12+
.arg(Arg::new("crate").hide(true))
1813
.arg(
1914
multi_opt(
2015
"add",
@@ -37,41 +32,38 @@ pub fn cli() -> Command {
3732
.subcommands([
3833
Command::new("add")
3934
.about("Name of a user or team to invite as an owner")
40-
.args([
35+
.arg(
4136
Arg::new("add")
4237
.required(true)
4338
.value_delimiter(',')
4439
.value_name("OWNER_NAME")
45-
.help("Name of the owner you want to invite"),
46-
Arg::new("crate")
47-
.value_name("CRATE_NAME")
48-
.help("Crate name that you want to manage the owner"),
49-
])
50-
.args(&add_registry_args())
51-
.override_usage("cargo owner add <OWNER_NAME> [CRATE_NAME] [OPTIONS]"),
40+
.hide(true)
41+
.help("Name of the owner you want to invite")
42+
)
43+
.args(add_registry_args())
44+
.override_usage(color_print::cstr!(
45+
"<cyan,bold>cargo owner add <<OWNER_NAME>> [CRATE_NAME] [OPTIONS]</>"
46+
)),
5247
Command::new("remove")
5348
.about("Name of a user or team to remove as an owner")
54-
.args([
49+
.arg(
5550
Arg::new("remove")
5651
.required(true)
5752
.value_delimiter(',')
5853
.value_name("OWNER_NAME")
59-
.help("Name of the owner you want to remove"),
60-
Arg::new("crate")
61-
.value_name("CRATE_NAME")
62-
.help("Crate name that you want to manage the owner"),
63-
])
64-
.args(&add_registry_args())
65-
.override_usage("cargo owner remove <OWNER_NAME> [CRATE_NAME] [OPTIONS]"),
54+
.hide(true)
55+
.help("Name of the owner you want to remove")
56+
)
57+
.args(add_registry_args())
58+
.override_usage(color_print::cstr!(
59+
"<cyan,bold>cargo owner remove <<OWNER_NAME>> [CRATE_NAME] [OPTIONS]</>"
60+
)),
6661
Command::new("list")
6762
.about("List owners of a crate")
68-
.arg(
69-
Arg::new("crate")
70-
.value_name("CRATE_NAME")
71-
.help("Crate name which you want to list all owner names"),
72-
)
73-
.args(&add_registry_args())
74-
.override_usage("cargo owner list [CRATE_NAME] [OPTIONS]"),
63+
.args(add_registry_args())
64+
.override_usage(color_print::cstr!(
65+
"<cyan,bold>cargo owner list [CRATE_NAME] [OPTIONS]</>"
66+
)),
7567
])
7668
.arg_index("Registry index URL to modify owners for")
7769
.arg_registry("Registry to modify owners for")
@@ -82,8 +74,10 @@ pub fn cli() -> Command {
8274
))
8375
}
8476

85-
fn add_registry_args() -> [Arg; 3] {
77+
fn add_registry_args() -> [Arg; 4] {
8678
[
79+
opt("crate", "Crate name that you want to manage the owner")
80+
.value_name("CRATE_NAME"),
8781
opt("index", "Registry index URL to modify owners for")
8882
.value_name("INDEX")
8983
.conflicts_with("registry"),

src/etc/_cargo

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,9 @@ _cargo() {
217217
owner)
218218
_arguments -s -S $common $registry \
219219
'(-a --add)'{-a,--add}'[specify name of a user or team to invite as an owner]:name' \
220-
'(add)'{add}'[specify name of a user or team to invite as an owner]:name' \
221220
'--index=[specify registry index]:index' \
222221
'(-l --list)'{-l,--list}'[list owners of a crate]' \
223-
'(list)'{list}'[list owners of a crate]' \
224222
'(-r --remove)'{-r,--remove}'[specify name of a user or team to remove as an owner]:name' \
225-
'(remove)'{remove}'[specify name of a user or team to remove as an owner]:name' \
226223
'--token=[specify API token to use when authenticating]:token' \
227224
'*: :_guard "^-*" "crate"'
228225
;;

src/etc/cargo.bashcomp.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ _cargo()
6969
local opt__login="$opt_common $opt_lock --registry"
7070
local opt__metadata="$opt_common $opt_feat $opt_mani $opt_lock --format-version=1 --no-deps --filter-platform"
7171
local opt__new="$opt_common $opt_lock --vcs --bin --lib --name --edition --registry"
72-
local opt__owner="$opt_common $opt_lock -a --add add -r --remove remove -l --list list --index --token --registry"
72+
local opt__owner="$opt_common $opt_lock add remove list -a --add -r --remove -l --list --index --token --registry"
73+
local opt__owner_add="$opt_common $opt_lock --crate --index --token --registry"
74+
local opt__owner_remove="$opt_common $opt_lock --crate --index --token --registry"
75+
local opt__owner_list="$opt_common $opt_lock --crate --index --token --registry"
7376
local opt__package="$opt_common $opt_mani $opt_feat $opt_lock $opt_parallel --allow-dirty -l --list --no-verify --no-metadata --target --target-dir"
7477
local opt__pkgid="$opt_common $opt_mani $opt_lock $opt_pkg"
7578
local opt__publish="$opt_common $opt_mani $opt_feat $opt_lock $opt_parallel --allow-dirty --dry-run --token --no-verify --index --registry --target --target-dir"
@@ -209,12 +212,12 @@ _get_names_from_array()
209212
line=${line##*=}
210213
line=${line%%\"}
211214
line=${line##*\"}
212-
names+=($line)
215+
names+=("$line")
213216
fi
214217
fi
215218

216219
last_line=$line
217-
done < $manifest
220+
done < "$manifest"
218221
echo "${names[@]}"
219222
}
220223

tests/testsuite/cargo_owner/add_help/stdout.log

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
Name of a user or team to invite as an owner
22

3-
Usage: cargo owner add <OWNER_NAME> [CRATE_NAME] [OPTIONS]
4-
5-
Arguments:
6-
<OWNER_NAME> Name of the owner you want to invite
7-
[CRATE_NAME] Crate name that you want to manage the owner
3+
Usage: cargo owner add <OWNER_NAME> [CRATE_NAME] [OPTIONS]
84

95
Options:
6+
--crate <CRATE_NAME> Crate name that you want to manage the owner
107
--index <INDEX> Registry index URL to modify owners for
118
--registry <REGISTRY> Registry to modify owners for
129
--token <TOKEN> API token to use when authenticating

tests/testsuite/cargo_owner/help/stdout.log

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
Manage the owners of a crate on the registry
22

3-
Usage: cargo[EXE] owner add <OWNER_NAME> [CRATE_NAME] [OPTIONS]
4-
cargo[EXE] owner remove <OWNER_NAME> [CRATE_NAME] [OPTIONS]
5-
cargo[EXE] owner list [CRATE_NAME] [OPTIONS]
6-
7-
Commands:
8-
add Name of a user or team to invite as an owner
9-
remove Name of a user or team to remove as an owner
10-
list List owners of a crate
3+
Usage: cargo owner [OPTIONS]
4+
cargo owner add <OWNER_NAME> [CRATE_NAME] [OPTIONS]
5+
cargo owner remove <OWNER_NAME> [CRATE_NAME] [OPTIONS]
6+
cargo owner list [CRATE_NAME] [OPTIONS]
117

128
Options:
139
--index <INDEX> Registry index URL to modify owners for
@@ -25,4 +21,28 @@ Manifest Options:
2521
--locked Require Cargo.lock is up to date
2622
--offline Run without accessing the network
2723

24+
cargo owner add:
25+
Name of a user or team to invite as an owner
26+
--crate <CRATE_NAME> Crate name that you want to manage the owner
27+
--index <INDEX> Registry index URL to modify owners for
28+
--registry <REGISTRY> Registry to modify owners for
29+
--token <TOKEN> API token to use when authenticating
30+
-h, --help Print help
31+
32+
cargo owner remove:
33+
Name of a user or team to remove as an owner
34+
--crate <CRATE_NAME> Crate name that you want to manage the owner
35+
--index <INDEX> Registry index URL to modify owners for
36+
--registry <REGISTRY> Registry to modify owners for
37+
--token <TOKEN> API token to use when authenticating
38+
-h, --help Print help
39+
40+
cargo owner list:
41+
List owners of a crate
42+
--crate <CRATE_NAME> Crate name that you want to manage the owner
43+
--index <INDEX> Registry index URL to modify owners for
44+
--registry <REGISTRY> Registry to modify owners for
45+
--token <TOKEN> API token to use when authenticating
46+
-h, --help Print help
47+
2848
Run `cargo help owner` for more detailed information.

tests/testsuite/cargo_owner/list_help/stdout.log

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
List owners of a crate
22

3-
Usage: cargo owner list [CRATE_NAME] [OPTIONS]
4-
5-
Arguments:
6-
[CRATE_NAME] Crate name which you want to list all owner names
3+
Usage: cargo owner list [CRATE_NAME] [OPTIONS]
74

85
Options:
6+
--crate <CRATE_NAME> Crate name that you want to manage the owner
97
--index <INDEX> Registry index URL to modify owners for
108
--registry <REGISTRY> Registry to modify owners for
119
--token <TOKEN> API token to use when authenticating

tests/testsuite/cargo_owner/remove_help/stdout.log

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ Name of a user or team to remove as an owner
22

33
Usage: cargo owner remove <OWNER_NAME> [CRATE_NAME] [OPTIONS]
44

5-
Arguments:
6-
<OWNER_NAME> Name of the owner you want to remove
7-
[CRATE_NAME] Crate name that you want to manage the owner
8-
95
Options:
6+
--crate <CRATE_NAME> Crate name that you want to manage the owner
107
--index <INDEX> Registry index URL to modify owners for
118
--registry <REGISTRY> Registry to modify owners for
129
--token <TOKEN> API token to use when authenticating

0 commit comments

Comments
 (0)