Repository navigation
feat(databases): show created_at in list and show commands #217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -258,6 +258,8 @@ struct DatabaseSummary { | |
| name: Option<String>, | ||
| #[serde(default)] | ||
| default_catalog: Option<String>, | ||
| #[serde(default)] | ||
| created_at: Option<String>, | ||
| } | ||
|
|
||
| /// CLI output shape for `databases get`. A curated, stably-ordered view mapped | ||
|
|
@@ -275,6 +277,8 @@ pub struct Database { | |
| #[serde(default)] | ||
| pub expires_at: Option<String>, | ||
| #[serde(default)] | ||
| pub created_at: Option<String>, | ||
| #[serde(default)] | ||
| attachments: Vec<DatabaseAttachment>, | ||
| } | ||
|
|
||
|
|
@@ -347,6 +351,7 @@ impl From<hotdata::models::DatabaseDetailResponse> for Database { | |
| default_catalog: Some(d.default_catalog), | ||
| default_connection_id: d.default_connection_id, | ||
| expires_at: d.expires_at.flatten(), | ||
| created_at: d.created_at.flatten(), | ||
| attachments: d | ||
| .attachments | ||
| .into_iter() | ||
|
|
@@ -360,12 +365,12 @@ impl From<hotdata::models::DatabaseDetailResponse> for Database { | |
| } | ||
|
|
||
| impl From<hotdata::models::DatabaseSummary> for DatabaseSummary { | ||
| /// Map the SDK's typed summary into the CLI's list-row output shape. | ||
| fn from(s: hotdata::models::DatabaseSummary) -> Self { | ||
| DatabaseSummary { | ||
| id: s.id, | ||
| name: s.name.flatten(), | ||
| default_catalog: Some(s.default_catalog), | ||
| created_at: s.created_at.flatten(), | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -386,7 +391,7 @@ pub(crate) fn get_database(api: &Api, id: &str) -> Result<Database, ApiError> { | |
| /// up worker" hint instead of an unexplained pause — `databases list` is a | ||
| /// common first command against an idle workspace. | ||
| fn list_database_summaries(api: &Api) -> Result<Vec<DatabaseSummary>, ApiError> { | ||
| block_with_wakeup(api, "Loading databases…", api.client().databases().list()) | ||
| block_with_wakeup(api, "Loading databases...", api.client().databases().list()) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. super nit: this swaps the Unicode ellipsis |
||
| .map(|r| r.databases.into_iter().map(DatabaseSummary::from).collect()) | ||
| } | ||
|
|
||
|
|
@@ -818,10 +823,14 @@ pub fn list(workspace_id: &str, format: &str) { | |
| marker.to_string(), | ||
| d.id.clone(), | ||
| d.name.as_deref().unwrap_or("-").to_string(), | ||
| d.created_at | ||
| .as_deref() | ||
| .map(crate::util::format_date) | ||
| .unwrap_or_else(|| "-".to_string()), | ||
| ] | ||
| }) | ||
| .collect(); | ||
| crate::output::table::print(&["", "ID", "NAME"], &rows); | ||
| crate::output::table::print(&["", "ID", "NAME", "CREATED"], &rows); | ||
| } | ||
| } | ||
| _ => unreachable!(), | ||
|
|
@@ -845,6 +854,13 @@ pub fn get(workspace_id: &str, id_or_name: &str, format: &str) { | |
| if let Some(c) = &db.default_catalog { | ||
| println!("{}{}", label("catalog:"), c.clone().cyan()); | ||
| } | ||
| if let Some(ts) = &db.created_at { | ||
| println!( | ||
| "{}{}", | ||
| label("created_at:"), | ||
| crate::util::format_date(ts).dark_grey() | ||
| ); | ||
| } | ||
| println!( | ||
| "{}{}", | ||
| label("default_connection_id:"), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super nit: this drops the existing doc comment
/// Map the SDK's typed summary into the CLI's list-row output shape.for no apparent reason. The siblingFrom<DatabaseDetailResponse>impl above still keeps its doc comment, so removing this one makes the two inconsistent. (not blocking)