Skip to content

Commit a67e301

Browse files
committed
feat(stac-cli): auto create collections when serving
1 parent adeb9ad commit a67e301

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

stac-cli/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1010
### Added
1111

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

1415
## [0.2.0] - 2024-08-12
1516

stac-cli/src/args.rs

+4
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ pub struct ServeArgs {
151151
/// The pgstac connection string.
152152
#[arg(long)]
153153
pub pgstac: Option<String>,
154+
155+
/// Don't auto-create collections for items that are missing them.
156+
#[arg(short, long)]
157+
pub dont_auto_create_collections: bool,
154158
}
155159

156160
/// Arguments for sorting a STAC value.

stac-cli/src/subcommand/serve.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ impl Subcommand {
1212
{
1313
let mut backend = stac_server::PgstacBackend::new_from_stringlike(pgstac).await?;
1414
if !args.href.is_empty() {
15-
backend.add_from_hrefs(&args.href).await?;
15+
backend
16+
.add_from_hrefs(&args.href, !args.dont_auto_create_collections)
17+
.await?;
1618
}
1719
let api = Api::new(backend, root)?;
1820
let router = stac_server::routes::from_api(api);
@@ -29,7 +31,9 @@ impl Subcommand {
2931
} else {
3032
let mut backend = MemoryBackend::new();
3133
if !args.href.is_empty() {
32-
backend.add_from_hrefs(&args.href).await?;
34+
backend
35+
.add_from_hrefs(&args.href, !args.dont_auto_create_collections)
36+
.await?;
3337
}
3438
let api = Api::new(backend, root)?;
3539
let router = stac_server::routes::from_api(api);

0 commit comments

Comments
 (0)