Skip to content

Commit 69b03b1

Browse files
committed
refactor(cli): greatly reduce the public api
1 parent 32566ef commit 69b03b1

File tree

16 files changed

+216
-194
lines changed

16 files changed

+216
-194
lines changed

cli/Cargo.toml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,13 @@ rust-version = "1.75"
1515
default = ["gdal", "geoparquet", "pgstac"]
1616
duckdb = ["dep:stac-duckdb", "dep:duckdb"]
1717
gdal = ["stac/gdal"]
18-
geoparquet = [
19-
"dep:bytes",
20-
"dep:geoarrow",
21-
"stac/geoparquet-compression",
22-
"parquet",
23-
]
18+
geoparquet = ["dep:geoarrow", "stac/geoparquet-compression", "parquet"]
2419
pgstac = ["stac-server/pgstac"]
2520
python = ["dep:pyo3", "pgstac", "geoparquet"]
2621

2722
[dependencies]
2823
axum = "0.7"
29-
bytes = { version = "1", optional = true }
24+
bytes = { version = "1" }
3025
clap = { version = "4", features = ["derive"] }
3126
duckdb = { version = "1", optional = true } # We have this dependency only to allow us to bundle it
3227
geoarrow = { version = "0.3", optional = true }

cli/src/args/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use tokio::sync::mpsc::Sender;
66

77
/// Arguments for the `item` subcommand.
88
#[derive(clap::Args, Debug)]
9-
pub struct Args {
9+
pub(crate) struct Args {
1010
/// The item id or asset href
1111
pub(crate) id_or_href: String,
1212

cli/src/args/items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use tokio::{sync::mpsc::Sender, task::JoinSet};
44

55
/// Arguments for the `items` subcommand.
66
#[derive(clap::Args, Debug)]
7-
pub struct Args {
7+
pub(crate) struct Args {
88
/// The asset hrefs
99
hrefs: Vec<String>,
1010

cli/src/args/migrate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use tokio::sync::mpsc::Sender;
55

66
/// Arguments for the `migrate` subcommand.
77
#[derive(clap::Args, Debug)]
8-
pub struct Args {
8+
pub(crate) struct Args {
99
/// The input file, if not provided or `-` the input will be read from standard input
1010
infile: Option<String>,
1111

cli/src/args/mod.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mod serve;
1010
mod translate;
1111
mod validate;
1212

13-
use crate::{Entry, Input, Output, Result, Value};
13+
use crate::{config::Entry, input::Input, output::Output, Result, Value};
1414
use clap::Parser;
1515
use tokio::sync::mpsc::Sender;
1616
use tokio::task::JoinHandle;
@@ -35,10 +35,14 @@ pub struct Args {
3535
#[arg(short, long, global = true)]
3636
output_format: Option<crate::output::Format>,
3737

38-
/// key=value pairs to use for the input object store
38+
/// key=value pairs to use for the output object store
3939
#[arg(short = 'c', long)]
4040
output_config: Vec<Entry>,
4141

42+
/// If the output is a local file, create its parent directories before creating the file
43+
#[arg(long, default_value_t = true)]
44+
create_parent_directories: bool,
45+
4246
/// Stream the items to output as ndjson, default behavior is to return them all at the end of the operation
4347
#[arg(short, long)]
4448
stream: bool,
@@ -69,10 +73,10 @@ pub struct Args {
6973
subcommand: Subcommand,
7074
}
7175

72-
/// A sucommand.
76+
/// A subcommand.
7377
#[derive(Debug, clap::Subcommand)]
7478
#[allow(clippy::large_enum_variant)]
75-
pub enum Subcommand {
79+
enum Subcommand {
7680
/// Create a STAC Item from an id or the href to an asset
7781
Item(item::Args),
7882

@@ -137,7 +141,9 @@ impl Args {
137141
}
138142
}),
139143
self.output_config,
140-
)?;
144+
self.create_parent_directories,
145+
)
146+
.await?;
141147
let value = if self.stream {
142148
if output.format != crate::output::Format::NdJson {
143149
tracing::warn!(

cli/src/args/search.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use tokio_stream::StreamExt;
99
use tracing::info;
1010

1111
#[derive(Debug, clap::Args)]
12-
pub struct Args {
12+
pub(crate) struct Args {
1313
/// The href of the STAC API or the stac-geoparquet file to search
1414
#[cfg(feature = "duckdb")]
1515
href: String,

cli/src/args/serve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const DEFAULT_COLLECTION_ID: &str = "auto-generated-collection";
1010

1111
/// Arguments for serving an API.
1212
#[derive(Debug, clap::Args)]
13-
pub struct Args {
13+
pub(crate) struct Args {
1414
/// Hrefs of collections, items, and item collections to load into the server on start
1515
///
1616
/// If this is a single `-`, the data will be read from standard input.

cli/src/args/translate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use tokio::sync::mpsc::Sender;
44

55
/// Arguments for the `translate` subcommand.
66
#[derive(clap::Args, Debug)]
7-
pub struct Args {
7+
pub(crate) struct Args {
88
/// The input file, if not provided or `-` the input will be read from standard input
99
infile: Option<String>,
1010

cli/src/args/validate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use tokio::sync::mpsc::Sender;
55

66
/// Arguments for the `validate` subcommand.
77
#[derive(clap::Args, Debug)]
8-
pub struct Args {
8+
pub(crate) struct Args {
99
/// The input file, if not provided or `-` the input will be read from standard input
1010
infile: Option<String>,
1111

cli/src/config.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
use std::{convert::Infallible, str::FromStr};
22

33
/// A collection of configuration entries.
4-
#[derive(Clone, Debug)]
5-
pub struct Config(Vec<Entry>);
4+
#[derive(Clone, Debug, Default)]
5+
pub(crate) struct Config(Vec<Entry>);
66

7-
/// key=value pairs for object store configuration
7+
/// `key=value`` pairs for object store configuration
88
#[derive(Clone, Debug)]
9-
pub struct Entry {
9+
pub(crate) struct Entry {
1010
key: String,
1111
value: String,
1212
}
1313

1414
impl Config {
1515
/// Returns an iterator over this config's key value pairs.
16-
pub fn iter(&self) -> impl Iterator<Item = (&str, &str)> {
16+
pub(crate) fn iter(&self) -> impl Iterator<Item = (&str, &str)> {
1717
self.0
1818
.iter()
1919
.map(|entry| (entry.key.as_str(), entry.value.as_str()))

0 commit comments

Comments
 (0)