Skip to content

Commit 3d3ba54

Browse files
authored
Miscellaneous CLI fixes (#346)
* show latest_major_change_at in the cli * fix broken `meta` cli command
1 parent 0e73689 commit 3d3ba54

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

rfd-cli/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ impl ProgenitorCliConfig for Context {
430430
.printer()
431431
.unwrap()
432432
.output_oauth_secret(reserialize(value)),
433+
"RfdWithoutContent" => self.printer().unwrap().output_rfd_meta(reserialize(value)),
433434
"Array_of_RfdWithoutContent" => {
434435
self.printer().unwrap().output_rfd_list(reserialize(value))
435436
}

rfd-cli/src/printer/json.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ impl CliOutput for RfdJsonPrinter {
7171
println!("{}", serde_json::to_string(&value).unwrap())
7272
}
7373

74+
fn output_rfd_meta(&self, value: types::RfdWithoutContent) {
75+
println!("{}", serde_json::to_string(&value).unwrap())
76+
}
77+
7478
fn output_rfd_list(&self, value: Vec<types::RfdWithoutContent>) {
7579
println!("{}", serde_json::to_string(&value).unwrap())
7680
}

rfd-cli/src/printer/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub trait CliOutput {
3131
fn output_oauth_redirect_uri(&self, value: types::OAuthClientRedirectUri) {}
3232
fn output_oauth_secret_initial(&self, value: types::InitialOAuthClientSecretResponse) {}
3333
fn output_oauth_secret(&self, value: types::OAuthClientSecret) {}
34+
fn output_rfd_meta(&self, value: types::RfdWithoutContent) {}
3435
fn output_rfd_list(&self, value: Vec<types::RfdWithoutContent>) {}
3536
fn output_rfd_full(&self, value: types::RfdWithRaw) {}
3637
fn output_rfd(&self, value: types::Rfd) {}
@@ -164,6 +165,13 @@ impl CliOutput for Printer {
164165
}
165166
}
166167

168+
fn output_rfd_meta(&self, value: types::RfdWithoutContent) {
169+
match self {
170+
Self::Json(printer) => printer.output_rfd_meta(value),
171+
Self::Tab(printer) => printer.output_rfd_meta(value),
172+
}
173+
}
174+
167175
fn output_rfd_list(&self, value: Vec<types::RfdWithoutContent>) {
168176
match self {
169177
Self::Json(printer) => printer.output_rfd_list(value),

rfd-cli/src/printer/tab.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ impl CliOutput for RfdTabPrinter {
101101
self.print_cli_output(&value, None);
102102
}
103103

104+
fn output_rfd_meta(&self, value: types::RfdWithoutContent) {
105+
self.print_cli_output(&value, None);
106+
}
107+
104108
fn output_rfd_list(&self, value: Vec<types::RfdWithoutContent>) {
105109
self.print_cli_output(&value, Some("rfds".to_string()));
106110
}
@@ -162,6 +166,15 @@ impl TabDisplay for types::Rfd {
162166
printer.print_field(tw, level, "id", &self.id);
163167
printer.print_field(tw, level, "rfd_number", &self.rfd_number);
164168
printer.print_field(tw, level, "visibility", &self.visibility.to_string());
169+
printer.print_field(
170+
tw,
171+
level,
172+
"latest_major_change_at",
173+
&self
174+
.latest_major_change_at
175+
.map(|d| d.to_string())
176+
.unwrap_or_else(|| "--".to_string()),
177+
);
165178
printer.print_field(
166179
tw,
167180
level,
@@ -484,6 +497,15 @@ impl TabDisplay for RfdWithoutContent {
484497
.map(|d| d.to_string())
485498
.unwrap_or_else(|| "--".to_string()),
486499
);
500+
printer.print_field(
501+
tw,
502+
level,
503+
"latest_major_change_at",
504+
&self
505+
.latest_major_change_at
506+
.map(|d| d.to_string())
507+
.unwrap_or_else(|| "--".to_string()),
508+
);
487509
}
488510
}
489511

@@ -557,6 +579,15 @@ impl TabDisplay for RfdWithRaw {
557579
.map(|d| d.to_string())
558580
.unwrap_or_else(|| "--".to_string()),
559581
);
582+
printer.print_field(
583+
tw,
584+
level,
585+
"latest_major_change_at",
586+
&self
587+
.latest_major_change_at
588+
.map(|d| d.to_string())
589+
.unwrap_or_else(|| "--".to_string()),
590+
);
560591
writeln!(tw, "");
561592
if let Some(content) = &self.content {
562593
writeln!(tw, "{}", content);

0 commit comments

Comments
 (0)