Support URLs as inputs for cat command

This commit is contained in:
Marcin Kulik
2025-08-30 21:49:30 +02:00
parent f41c79679b
commit c0cdb946f2

View File

@@ -5,6 +5,7 @@ use anyhow::{anyhow, Result};
use crate::asciicast::{self, Asciicast, Encoder, Event, EventData, Version}; use crate::asciicast::{self, Asciicast, Encoder, Event, EventData, Version};
use crate::cli; use crate::cli;
use crate::util;
impl cli::Cat { impl cli::Cat {
pub fn run(self) -> Result<()> { pub fn run(self) -> Result<()> {
@@ -49,7 +50,13 @@ impl cli::Cat {
} }
fn open_input_files(&self) -> Result<Vec<Asciicast>> { fn open_input_files(&self) -> Result<Vec<Asciicast>> {
self.file.iter().map(asciicast::open_from_path).collect() self.file
.iter()
.map(|filename| {
let path = util::get_local_path(filename)?;
asciicast::open_from_path(&*path)
})
.collect()
} }
fn get_encoder(&self, version: Version) -> Result<Box<dyn Encoder>> { fn get_encoder(&self, version: Version) -> Result<Box<dyn Encoder>> {