Skip to content

Commit

Permalink
fix: make GetSearch::ids also comma-deliminted
Browse files Browse the repository at this point in the history
  • Loading branch information
gadomski committed Apr 28, 2024
1 parent 07c250d commit 9aa3652
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
20 changes: 12 additions & 8 deletions stac-api/src/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ pub struct GetSearch {
#[serde(skip_serializing_if = "Option::is_none")]
pub intersects: Option<String>,

/// Array of Item ids to return.
/// Comma-delimited list of Item ids to return.
#[serde(skip_serializing_if = "Option::is_none")]
pub ids: Option<Vec<String>>,
pub ids: Option<String>,

/// Comma-separated list of one or more Collection IDs that each matching Item must be in.
/// Comma-delimited list of one or more Collection IDs that each matching Item must be in.
#[serde(skip_serializing_if = "Option::is_none")]
pub collections: Option<String>,
}
Expand Down Expand Up @@ -222,10 +222,11 @@ impl TryFrom<Search> for GetSearch {
.map(|intersects| serde_json::to_string(&intersects))
.transpose()?;
let collections = search.collections.map(|collections| collections.join(","));
let ids = search.ids.map(|ids| ids.join(","));
Ok(GetSearch {
items: get_items,
intersects: intersects,
ids: search.ids,
intersects,
ids,
collections,
})
}
Expand All @@ -243,11 +244,14 @@ impl TryFrom<GetSearch> for Search {
let collections = get_search
.collections
.map(|collections| collections.split(',').map(|s| s.to_string()).collect());
let ids = get_search
.ids
.map(|ids| ids.split(',').map(|s| s.to_string()).collect());
Ok(Search {
items,
intersects: intersects,
ids: get_search.ids,
collections: collections,
intersects,
ids,
collections,
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion stac-cli/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl Args {
bbox: &Option<String>,
datetime: &Option<String>,
intersects: &Option<String>,
ids: &Option<Vec<String>>,
ids: &Option<String>,
collections: &Option<String>,
fields: &Option<String>,
sortby: &Option<String>,
Expand Down
4 changes: 2 additions & 2 deletions stac-cli/src/subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ pub enum Subcommand {
#[arg(long)]
intersects: Option<String>,

/// Array of Item ids to return.
/// Comma-delimited list of one ore more Item ids to return.
#[arg(short, long)]
ids: Option<Vec<String>>,
ids: Option<String>,

/// Comma-delimited list of one or more Collection IDs that each matching Item must be in.
#[arg(short, long)]
Expand Down

0 comments on commit 9aa3652

Please sign in to comment.