2025-03-25 23:02:35 +01:00
|
|
|
use anyhow::Result;
|
2025-06-20 17:09:21 +02:00
|
|
|
use tokio::runtime::Runtime;
|
2025-03-25 23:02:35 +01:00
|
|
|
|
2024-04-16 12:02:51 +02:00
|
|
|
use crate::api;
|
2024-01-23 11:52:28 +01:00
|
|
|
use crate::asciicast;
|
2024-04-29 16:44:18 +02:00
|
|
|
use crate::cli;
|
2023-12-27 23:14:24 +01:00
|
|
|
use crate::config::Config;
|
2023-12-21 16:23:40 +01:00
|
|
|
|
2025-03-12 13:15:02 +01:00
|
|
|
impl cli::Upload {
|
2025-05-29 13:16:37 +02:00
|
|
|
pub fn run(self) -> Result<()> {
|
2025-06-20 17:09:21 +02:00
|
|
|
Runtime::new()?.block_on(self.do_run())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async fn do_run(self) -> Result<()> {
|
2025-05-29 13:16:37 +02:00
|
|
|
let config = Config::new(self.server_url.clone())?;
|
2025-06-02 21:59:10 +02:00
|
|
|
let _ = asciicast::open_from_path(&self.file)?;
|
2025-07-09 16:01:54 +02:00
|
|
|
let response = api::create_recording(&self.file, &config).await?;
|
2024-04-16 12:02:51 +02:00
|
|
|
println!("{}", response.message.unwrap_or(response.url));
|
2023-12-21 16:23:40 +01:00
|
|
|
|
2023-12-22 11:45:50 +01:00
|
|
|
Ok(())
|
|
|
|
|
}
|
2023-12-23 22:26:39 +01:00
|
|
|
}
|