polaranges 0.3.2

Rust-first genomic range operations on top of Polars DataFrames
Documentation
use clap::Args;

use crate::commands::spec::IntervalCommandSpec;
use crate::commands::{CommandError, Result};

/// Compat mode will stay thin: it should eventually translate bedtools-style
/// syntax into the same shared command specs used by the regular mode.
#[derive(Args, Clone, Debug, Default, PartialEq, Eq)]
pub struct CompatCli {
    #[arg(
        trailing_var_arg = true,
        allow_hyphen_values = true,
        value_name = "ARGS"
    )]
    pub argv: Vec<String>,
}

pub fn translate_compat_cli(_cli: CompatCli) -> Result<IntervalCommandSpec> {
    Err(CommandError::CompatModeNotYetImplemented)
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::commands::{execute::run_command, ExecOptions};

    #[test]
    fn compat_boundary_already_targets_shared_command_specs() {
        let translator: fn(CompatCli) -> Result<IntervalCommandSpec> = translate_compat_cli;
        let dispatcher: fn(&IntervalCommandSpec, &ExecOptions) -> crate::commands::Result<()> =
            run_command;
        let _ = (translator, dispatcher);

        let err = translate_compat_cli(CompatCli {
            argv: vec![
                "intersect".to_owned(),
                "-a".to_owned(),
                "left.bed".to_owned(),
            ],
        })
        .unwrap_err();
        assert!(matches!(err, CommandError::CompatModeNotYetImplemented));
    }
}