fix(rust): warn when browse --depth ignored, extract page-size const, tidy clones
Warn on stderr when --parent-gobject-id and --depth>0 are both supplied since depth is silently ignored in the single-level parent path. Also updates the --depth arg doc to document this. Extracts BROWSE_PAGE_SIZE const (500) with a cross-reference to galaxy.rs instead of a bare literal. Removes three redundant .clone() calls in BrowseChildrenOptions construction since the originals are not used after the struct is built.
This commit is contained in:
@@ -423,6 +423,7 @@ enum GalaxyCommand {
|
||||
historized_only: bool,
|
||||
/// Number of additional levels to eagerly expand beneath each returned
|
||||
/// node. 0 (the default) prints only the requested level.
|
||||
/// Ignored when --parent-gobject-id is specified.
|
||||
#[arg(long, default_value_t = 0)]
|
||||
depth: usize,
|
||||
#[arg(long)]
|
||||
@@ -1156,11 +1157,15 @@ async fn run_galaxy(command: GalaxyCommand) -> Result<(), Error> {
|
||||
depth,
|
||||
json,
|
||||
} => {
|
||||
if parent_gobject_id.is_some() && depth > 0 {
|
||||
eprintln!("warning: --depth is ignored when --parent-gobject-id is specified");
|
||||
}
|
||||
|
||||
let mut client = connect_galaxy(connection).await?;
|
||||
let options = BrowseChildrenOptions {
|
||||
category_ids: category_ids.clone(),
|
||||
template_chain_contains: template_chain_contains.clone(),
|
||||
tag_name_glob: tag_name_glob.clone(),
|
||||
category_ids,
|
||||
template_chain_contains,
|
||||
tag_name_glob,
|
||||
include_attributes: include_attributes.then_some(true),
|
||||
alarm_bearing_only,
|
||||
historized_only,
|
||||
@@ -1201,6 +1206,11 @@ async fn run_galaxy(command: GalaxyCommand) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Page size used for the raw `BrowseChildren` RPC when fetching a single
|
||||
/// level via `--parent-gobject-id`. Mirrors `BROWSE_CHILDREN_PAGE_SIZE` in
|
||||
/// `galaxy.rs` (the library's lazy-browse helper uses the same value).
|
||||
const BROWSE_PAGE_SIZE: i32 = 500;
|
||||
|
||||
/// Drive `BrowseChildren` paging by hand for a single parent and return the
|
||||
/// flattened child list. Used by the `browse --parent-gobject-id` path, which
|
||||
/// surfaces one level of children rather than the lazy root-tree walk.
|
||||
@@ -1219,7 +1229,7 @@ async fn browse_children_one_level(
|
||||
let mut seen: HashSet<String> = HashSet::new();
|
||||
loop {
|
||||
let request = BrowseChildrenRequest {
|
||||
page_size: 500,
|
||||
page_size: BROWSE_PAGE_SIZE,
|
||||
page_token: page_token.clone(),
|
||||
category_ids: options.category_ids.clone(),
|
||||
template_chain_contains: options.template_chain_contains.clone(),
|
||||
|
||||
Reference in New Issue
Block a user