television_previewers::previewers::command

Function format_command

Source
pub fn format_command(command: &PreviewCommand, entry: &Entry) -> String
Expand description

Format the command with the entry name and provided placeholders

ยงExample

use television_channels::entry::{PreviewCommand, PreviewType, Entry};
use television_previewers::previewers::command::format_command;

let command = PreviewCommand {
    command: "something {} {2} {0}".to_string(),
    delimiter: ":".to_string(),
};
let entry = Entry::new("a:given:entry:to:preview".to_string(), PreviewType::Command(command.clone()));
let formatted_command = format_command(&command, &entry);

assert_eq!(formatted_command, "something 'a:given:entry:to:preview' 'entry' 'a'");