holodeck_lib/commands/
command.rs1use std::path::{Path, PathBuf};
2
3use anyhow::Result;
4
5#[enum_dispatch::enum_dispatch]
7pub trait Command {
8 fn execute(&self) -> Result<()>;
13}
14
15#[must_use]
19pub fn output_path(prefix: &Path, suffix: &str) -> PathBuf {
20 PathBuf::from(format!("{}{suffix}", prefix.to_string_lossy()))
21}
22
23#[cfg(test)]
24mod tests {
25 use super::*;
26
27 #[test]
28 fn test_output_path_simple() {
29 let result = output_path(Path::new("out/sample"), ".r1.fastq.gz");
30 assert_eq!(result, PathBuf::from("out/sample.r1.fastq.gz"));
31 }
32
33 #[test]
34 fn test_output_path_no_directory() {
35 let result = output_path(Path::new("prefix"), ".txt");
36 assert_eq!(result, PathBuf::from("prefix.txt"));
37 }
38}