Skip to content

Commit

Permalink
feat(stac-cli): auto create collections when serving
Browse files Browse the repository at this point in the history
  • Loading branch information
gadomski committed Aug 28, 2024
1 parent adeb9ad commit a67e301
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions stac-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Added

- Geoparquet support ([#300](https://github.com/stac-utils/stac-rs/pull/300))
- Auto-create collections when serving ([#304](https://github.com/stac-utils/stac-rs/pull/304))

## [0.2.0] - 2024-08-12

Expand Down
4 changes: 4 additions & 0 deletions stac-cli/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ pub struct ServeArgs {
/// The pgstac connection string.
#[arg(long)]
pub pgstac: Option<String>,

/// Don't auto-create collections for items that are missing them.
#[arg(short, long)]
pub dont_auto_create_collections: bool,
}

/// Arguments for sorting a STAC value.
Expand Down
8 changes: 6 additions & 2 deletions stac-cli/src/subcommand/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ impl Subcommand {
{
let mut backend = stac_server::PgstacBackend::new_from_stringlike(pgstac).await?;
if !args.href.is_empty() {
backend.add_from_hrefs(&args.href).await?;
backend
.add_from_hrefs(&args.href, !args.dont_auto_create_collections)
.await?;
}
let api = Api::new(backend, root)?;
let router = stac_server::routes::from_api(api);
Expand All @@ -29,7 +31,9 @@ impl Subcommand {
} else {
let mut backend = MemoryBackend::new();
if !args.href.is_empty() {
backend.add_from_hrefs(&args.href).await?;
backend
.add_from_hrefs(&args.href, !args.dont_auto_create_collections)
.await?;
}
let api = Api::new(backend, root)?;
let router = stac_server::routes::from_api(api);
Expand Down

0 comments on commit a67e301

Please sign in to comment.