Skip to main content

select_target

Function select_target 

Source
pub fn select_target<'a>(
    targets: &'a [TargetInfo],
    tab: Option<&str>,
) -> Result<&'a TargetInfo, AppError>
Expand description

Select a target from a list based on the --tab option.

  • None → first target with target_type == "page"
  • Some(value) → try as numeric index, then as target ID

This is a pure function for testability.

§Errors

Returns AppError::no_page_targets() if no page-type target exists, or AppError::target_not_found() if the specified tab cannot be matched.