#!/usr/bin/env bash # ============================================================================= # scripts/add-genome.sh # Helper to add a single new genome to the existing infrastructure. # ============================================================================= set -euo pipefail source "lib/output.sh" source "globals.env" source "registry.sh" GENOME_NAME="${1:-}" GENOME_DESC="${2:-}" GENOME_LINKED="${3:-}" # optional: linked project repo reference if [[ -z "$GENOME_NAME" || -z "$GENOME_DESC" ]]; then error "Missing arguments." echo "Usage: $0 [linked-repo]" exit 1 fi step "Adding New Genome: ${GENOME_NAME}" # Build a 3-field registry entry (linked_repo may be empty) GENOMES=("${GENOME_NAME}|${GENOME_DESC}|${GENOME_LINKED}") # NOTE — Maintenance smell # We source setup-genomes.sh as a library/orchestrator hybrid. This works because: # - registry.sh is guarded against double-source (idempotent guard) # - setup-genomes.sh checks WORK_DIR before re-sourcing registry.sh # - GENOMES is built locally just before the source, so it is not clobbered # However, sourcing an orchestration script as a library makes the control flow # harder to trace. If this grows, refactor into a shared function (e.g. setup_one_genome) # called by both add-genome.sh and setup-genomes.sh. source "scripts/setup-genomes.sh" success "Genome '${GENOME_NAME}' added and linked successfully!"