mirror of
https://github.com/asciinema/asciinema.git
synced 2025-12-15 19:28:00 +01:00
Pass session title to the server
This commit is contained in:
@@ -149,6 +149,10 @@ pub struct Stream {
|
||||
#[arg(long, value_name = "VARS")]
|
||||
pub rec_env: Option<String>,
|
||||
|
||||
/// Title of the session
|
||||
#[arg(short, long)]
|
||||
pub title: Option<String>,
|
||||
|
||||
/// Headless mode, i.e. don't use TTY for input/output
|
||||
#[arg(long)]
|
||||
pub headless: bool,
|
||||
@@ -204,7 +208,7 @@ pub struct Session {
|
||||
#[arg(long, conflicts_with = "append")]
|
||||
pub overwrite: bool,
|
||||
|
||||
/// Title of the recording
|
||||
/// Title of the session
|
||||
#[arg(short, long)]
|
||||
pub title: Option<String>,
|
||||
|
||||
|
||||
@@ -71,7 +71,16 @@ impl cli::Session {
|
||||
let mut relay = self
|
||||
.stream_remote
|
||||
.take()
|
||||
.map(|target| get_relay(target, &config, term_type, term_version, &env))
|
||||
.map(|target| {
|
||||
get_relay(
|
||||
target,
|
||||
&config,
|
||||
term_type,
|
||||
term_version,
|
||||
self.title.take(),
|
||||
&env,
|
||||
)
|
||||
})
|
||||
.transpose()?;
|
||||
|
||||
let relay_id = relay.as_ref().map(|r| r.id());
|
||||
@@ -385,13 +394,14 @@ fn get_relay(
|
||||
config: &Config,
|
||||
term_type: Option<String>,
|
||||
term_version: Option<String>,
|
||||
title: Option<String>,
|
||||
env: &HashMap<String, String>,
|
||||
) -> Result<Relay> {
|
||||
match target {
|
||||
RelayTarget::StreamId(id) => {
|
||||
let stream = api::create_user_stream(id, config)?;
|
||||
let ws_producer_url =
|
||||
build_producer_url(&stream.ws_producer_url, term_type, term_version, env)?;
|
||||
build_producer_url(&stream.ws_producer_url, term_type, term_version, title, env)?;
|
||||
|
||||
Ok(Relay {
|
||||
ws_producer_url,
|
||||
@@ -410,6 +420,7 @@ fn build_producer_url(
|
||||
url: &str,
|
||||
term_type: Option<String>,
|
||||
term_version: Option<String>,
|
||||
title: Option<String>,
|
||||
env: &HashMap<String, String>,
|
||||
) -> Result<Url> {
|
||||
let mut url: Url = url.parse()?;
|
||||
@@ -427,6 +438,10 @@ fn build_producer_url(
|
||||
params.push(("shell".to_string(), shell));
|
||||
}
|
||||
|
||||
if let Some(title) = title {
|
||||
params.push(("title".to_string(), title));
|
||||
}
|
||||
|
||||
for (k, v) in env {
|
||||
params.push((format!("env[{k}]"), v.to_string()));
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ fn main() -> anyhow::Result<()> {
|
||||
overwrite: false,
|
||||
command: stream.command,
|
||||
rec_env: stream.rec_env,
|
||||
title: None,
|
||||
title: stream.title,
|
||||
idle_time_limit: None,
|
||||
headless: stream.headless,
|
||||
window_size: stream.window_size,
|
||||
|
||||
Reference in New Issue
Block a user