Skip to content

Commit fb21213

Browse files
Varun NuthalapatiVarun Nuthalapati
authored andcommitted
fixup: read --format from parent ArgMatches; avoid variable shadowing
Rename the subcommand ArgMatches variable from `matches` to `sub_matches` so the outer `matches` is still in scope. Read the global --format flag from the parent matches rather than the subcommand matches, ensuring clap v4 correctly resolves the globally-defined argument.
1 parent c1e20d5 commit fb21213

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

crates/google-workspace-cli/src/helpers/docs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ TIPS:
6666
_sanitize_config: &'a crate::helpers::modelarmor::SanitizeConfig,
6767
) -> Pin<Box<dyn Future<Output = Result<bool, GwsError>> + Send + 'a>> {
6868
Box::pin(async move {
69-
if let Some(matches) = matches.subcommand_matches("+write") {
70-
let (params_str, body_str, scopes) = build_write_request(matches, doc)?;
69+
if let Some(sub_matches) = matches.subcommand_matches("+write") {
70+
let (params_str, body_str, scopes) = build_write_request(sub_matches, doc)?;
7171
let output_format = matches
7272
.get_one::<String>("format")
7373
.map(|s| crate::formatter::OutputFormat::from_str(s))

crates/google-workspace-cli/src/helpers/sheets.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ TIPS:
109109
_sanitize_config: &'a crate::helpers::modelarmor::SanitizeConfig,
110110
) -> Pin<Box<dyn Future<Output = Result<bool, GwsError>> + Send + 'a>> {
111111
Box::pin(async move {
112-
if let Some(matches) = matches.subcommand_matches("+append") {
113-
let config = parse_append_args(matches);
112+
if let Some(sub_matches) = matches.subcommand_matches("+append") {
113+
let config = parse_append_args(sub_matches);
114114
let (params_str, body_str, scopes) = build_append_request(&config, doc)?;
115115
let output_format = matches
116116
.get_one::<String>("format")
@@ -161,8 +161,8 @@ TIPS:
161161
return Ok(true);
162162
}
163163

164-
if let Some(matches) = matches.subcommand_matches("+read") {
165-
let config = parse_read_args(matches);
164+
if let Some(sub_matches) = matches.subcommand_matches("+read") {
165+
let config = parse_read_args(sub_matches);
166166
let (params_str, scopes) = build_read_request(&config, doc)?;
167167
let output_format = matches
168168
.get_one::<String>("format")

0 commit comments

Comments
 (0)