Rename "recording" config file section to "session"

This commit is contained in:
Marcin Kulik
2025-08-29 21:20:56 +02:00
parent 9d943b4517
commit e2584a808c
3 changed files with 23 additions and 23 deletions

View File

@@ -118,7 +118,7 @@ pub struct Record {
)] )]
pub output_format: Option<Format>, pub output_format: Option<Format>,
/// Specify the command to execute in the recording session. If not provided, asciinema will use your default shell from the $SHELL environment variable. This can be any command with arguments, for example: --command "python script.py" or --command "bash -l". Can also be set via config file option recording.command. /// Specify the command to execute in the recording session. If not provided, asciinema will use your default shell from the $SHELL environment variable. This can be any command with arguments, for example: --command "python script.py" or --command "bash -l". Can also be set via config file option session.command.
#[arg( #[arg(
short, short,
long, long,
@@ -127,7 +127,7 @@ pub struct Record {
)] )]
pub command: Option<String>, pub command: Option<String>,
/// Enable recording of keyboard input in addition to terminal output. When enabled, both what you type and what appears on the screen will be captured. Note that sensitive input like passwords will also be recorded when this option is enabled. Can also be set via the config file option recording.cap_input. /// Enable recording of keyboard input in addition to terminal output. When enabled, both what you type and what appears on the screen will be captured. Note that sensitive input like passwords will also be recorded when this option is enabled. Can also be set via the config file option session.cap_input.
#[arg( #[arg(
long, long,
short = 'I', short = 'I',
@@ -137,7 +137,7 @@ pub struct Record {
)] )]
pub cap_input: bool, pub cap_input: bool,
/// Specify which environment variables to capture and include in the recording metadata. This helps ensure the recording context is preserved, e.g., for auditing. Provide a comma-separated list of variable names, for example: --rec-env "USER,SHELL,TERM". If not specified, only the SHELL variable is captured by default. Can also be set via the config file option recording.cap_env. /// Specify which environment variables to capture and include in the recording metadata. This helps ensure the recording context is preserved, e.g., for auditing. Provide a comma-separated list of variable names, for example: --rec-env "USER,SHELL,TERM". If not specified, only the SHELL variable is captured by default. Can also be set via the config file option session.cap_env.
#[arg( #[arg(
long, long,
value_name = "VARS", value_name = "VARS",
@@ -163,7 +163,7 @@ pub struct Record {
#[arg(short, long, help = "Title of the recording", long_help)] #[arg(short, long, help = "Title of the recording", long_help)]
pub title: Option<String>, pub title: Option<String>,
/// Limit the maximum idle time recorded between terminal events to the specified number of seconds. Long pauses (such as when you step away from the terminal) will be capped at this duration in the recording, making playback more watchable. For example, --idle-time-limit 2.0 will ensure no pause longer than 2 seconds appears in the recording. Note that this option doesn't alter the original (captured) timing information and instead embeds the idle time limit value in the metadata, which is interpreted by session players at playback time. This allows tweaking of the limit after recording. Can also be set via the config file option recording.idle_time_limit. /// Limit the maximum idle time recorded between terminal events to the specified number of seconds. Long pauses (such as when you step away from the terminal) will be capped at this duration in the recording, making playback more watchable. For example, --idle-time-limit 2.0 will ensure no pause longer than 2 seconds appears in the recording. Note that this option doesn't alter the original (captured) timing information and instead embeds the idle time limit value in the metadata, which is interpreted by session players at playback time. This allows tweaking of the limit after recording. Can also be set via the config file option session.idle_time_limit.
#[arg( #[arg(
short, short,
long, long,
@@ -257,7 +257,7 @@ pub struct Stream {
#[arg(short, long, value_name = "STREAM-ID|WS-URL", default_missing_value = "", num_args = 0..=1, value_parser = validate_forward_target, help = "Stream via remote asciinema server", long_help)] #[arg(short, long, value_name = "STREAM-ID|WS-URL", default_missing_value = "", num_args = 0..=1, value_parser = validate_forward_target, help = "Stream via remote asciinema server", long_help)]
pub remote: Option<RelayTarget>, pub remote: Option<RelayTarget>,
/// Specify the command to execute in the streaming session. If not provided, asciinema will use your default shell from the $SHELL environment variable. This can be any command with arguments, for example: --command "python script.py" or --command "bash -l". Can also be set via config file option recording.command. /// Specify the command to execute in the streaming session. If not provided, asciinema will use your default shell from the $SHELL environment variable. This can be any command with arguments, for example: --command "python script.py" or --command "bash -l". Can also be set via config file option session.command.
#[arg( #[arg(
short, short,
long, long,
@@ -266,11 +266,11 @@ pub struct Stream {
)] )]
pub command: Option<String>, pub command: Option<String>,
/// Enable recording of keyboard input in addition to terminal output. When enabled, both what you type and what appears on the screen will be captured. Note that sensitive input like passwords will also be recorded when this option is enabled. If the server has stream recording enabled then keyboard input will be included in the recording file created on the server side. Can also be set via the config file option recording.cap_input. /// Enable recording of keyboard input in addition to terminal output. When enabled, both what you type and what appears on the screen will be captured. Note that sensitive input like passwords will also be recorded when this option is enabled. If the server has stream recording enabled then keyboard input will be included in the recording file created on the server side. Can also be set via the config file option session.cap_input.
#[arg(long, short = 'I', help = "Enable input (keyboard) capture", long_help)] #[arg(long, short = 'I', help = "Enable input (keyboard) capture", long_help)]
pub cap_input: bool, pub cap_input: bool,
/// Specify which environment variables to capture and include in the stream metadata. Provide a comma-separated list of variable names, for example: --rec-env "USER,SHELL,TERM". If not specified, only the SHELL variable is captured by default. If the server has stream recording enabled then these environment variables will be included in the recording file created on the server side. Can also be set via the config file option recording.cap_env. /// Specify which environment variables to capture and include in the stream metadata. Provide a comma-separated list of variable names, for example: --rec-env "USER,SHELL,TERM". If not specified, only the SHELL variable is captured by default. If the server has stream recording enabled then these environment variables will be included in the recording file created on the server side. Can also be set via the config file option session.cap_env.
#[arg( #[arg(
long, long,
value_name = "VARS", value_name = "VARS",
@@ -340,7 +340,7 @@ pub struct Session {
#[arg(short = 'r', long, value_name = "STREAM-ID|WS-URL", default_missing_value = "", num_args = 0..=1, value_parser = validate_forward_target, help = "Stream via remote asciinema server", long_help)] #[arg(short = 'r', long, value_name = "STREAM-ID|WS-URL", default_missing_value = "", num_args = 0..=1, value_parser = validate_forward_target, help = "Stream via remote asciinema server", long_help)]
pub stream_remote: Option<RelayTarget>, pub stream_remote: Option<RelayTarget>,
/// Specify the command to execute in the session. If not provided, asciinema will use your default shell from the $SHELL environment variable. This can be any command with arguments, for example: --command "python script.py" or --command "bash -l". Can also be set via config file option recording.command. /// Specify the command to execute in the session. If not provided, asciinema will use your default shell from the $SHELL environment variable. This can be any command with arguments, for example: --command "python script.py" or --command "bash -l". Can also be set via config file option session.command.
#[arg( #[arg(
short, short,
long, long,
@@ -349,11 +349,11 @@ pub struct Session {
)] )]
pub command: Option<String>, pub command: Option<String>,
/// Enable recording of keyboard input in addition to terminal output. When enabled, both what you type and what appears on the screen will be captured. Note that sensitive input like passwords will also be recorded when this option is enabled. If the server has stream recording enabled then keyboard input will be included in the recording file created on the server side. Can also be set via the config file option recording.cap_input. /// Enable recording of keyboard input in addition to terminal output. When enabled, both what you type and what appears on the screen will be captured. Note that sensitive input like passwords will also be recorded when this option is enabled. If the server has stream recording enabled then keyboard input will be included in the recording file created on the server side. Can also be set via the config file option session.cap_input.
#[arg(long, short = 'I', help = "Enable input (keyboard) capture", long_help)] #[arg(long, short = 'I', help = "Enable input (keyboard) capture", long_help)]
pub cap_input: bool, pub cap_input: bool,
/// Specify which environment variables to capture and include in the session metadata. Provide a comma-separated list of variable names, for example: --rec-env "USER,SHELL,TERM". If not specified, only the SHELL variable is captured by default. If the server has stream recording enabled then these environment variables will be included in the recording file created on the server side. Can also be set via config file option recording.cap_env. /// Specify which environment variables to capture and include in the session metadata. Provide a comma-separated list of variable names, for example: --rec-env "USER,SHELL,TERM". If not specified, only the SHELL variable is captured by default. If the server has stream recording enabled then these environment variables will be included in the recording file created on the server side. Can also be set via config file option session.cap_env.
#[arg( #[arg(
long, long,
value_name = "VARS", value_name = "VARS",
@@ -379,7 +379,7 @@ pub struct Session {
#[arg(short, long, help = "Title of the session", long_help)] #[arg(short, long, help = "Title of the session", long_help)]
pub title: Option<String>, pub title: Option<String>,
/// Limit the maximum idle time recorded between terminal events to the specified number of seconds. Long pauses (such as when you step away from the terminal) will be capped at this duration in the recording, making playback more watchable. For example, --idle-time-limit 2.0 will ensure no pause longer than 2 seconds appears in the recording. Only applies when --output-file is specified. Note that this option doesn't alter the original (captured) timing information and instead it embeds the idle time limit value in the metadata, which is interpreted by session players at playback time. This allows tweaking of the limit after recording. Can also be set via config file option recording.idle_time_limit. /// Limit the maximum idle time recorded between terminal events to the specified number of seconds. Long pauses (such as when you step away from the terminal) will be capped at this duration in the recording, making playback more watchable. For example, --idle-time-limit 2.0 will ensure no pause longer than 2 seconds appears in the recording. Only applies when --output-file is specified. Note that this option doesn't alter the original (captured) timing information and instead it embeds the idle time limit value in the metadata, which is interpreted by session players at playback time. This allows tweaking of the limit after recording. Can also be set via config file option session.idle_time_limit.
#[arg( #[arg(
short, short,
long, long,

View File

@@ -48,10 +48,10 @@ impl cli::Session {
async fn do_run(&mut self) -> Result<i32> { async fn do_run(&mut self) -> Result<i32> {
let config = Config::new(self.server_url.clone())?; let config = Config::new(self.server_url.clone())?;
let command = self.get_command(&config.recording); let command = self.get_command(&config.session);
let keys = get_key_bindings(&config.recording)?; let keys = get_key_bindings(&config.session)?;
let notifier = get_notifier(&config); let notifier = get_notifier(&config);
let metadata = self.get_session_metadata(&config.recording).await?; let metadata = self.get_session_metadata(&config.session).await?;
let file_writer = self.get_file_writer(&metadata, notifier.clone()).await?; let file_writer = self.get_file_writer(&metadata, notifier.clone()).await?;
let listener = self.get_listener().await?; let listener = self.get_listener().await?;
let relay = self.get_relay(&metadata, &config).await?; let relay = self.get_relay(&metadata, &config).await?;
@@ -131,7 +131,7 @@ impl cli::Session {
command, command,
extra_env, extra_env,
tty.as_mut(), tty.as_mut(),
self.cap_input || config.recording.cap_input, self.cap_input || config.session.cap_input,
outputs, outputs,
keys, keys,
notifier, notifier,
@@ -160,11 +160,11 @@ impl cli::Session {
Ok(exit_status) Ok(exit_status)
} }
fn get_command(&self, config: &config::Recording) -> Option<String> { fn get_command(&self, config: &config::Session) -> Option<String> {
self.command.as_ref().cloned().or(config.command.clone()) self.command.as_ref().cloned().or(config.command.clone())
} }
async fn get_session_metadata(&self, config: &config::Recording) -> Result<Metadata> { async fn get_session_metadata(&self, config: &config::Session) -> Result<Metadata> {
Ok(Metadata { Ok(Metadata {
time: SystemTime::now(), time: SystemTime::now(),
term: self.get_term_info().await?, term: self.get_term_info().await?,
@@ -438,7 +438,7 @@ impl Relay {
} }
} }
fn get_key_bindings(config: &config::Recording) -> Result<KeyBindings> { fn get_key_bindings(config: &config::Session) -> Result<KeyBindings> {
let mut keys = KeyBindings::default(); let mut keys = KeyBindings::default();
if let Some(key) = config.prefix_key()? { if let Some(key) = config.prefix_key()? {
@@ -456,7 +456,7 @@ fn get_key_bindings(config: &config::Recording) -> Result<KeyBindings> {
Ok(keys) Ok(keys)
} }
fn capture_env(var_names: Option<String>, config: &config::Recording) -> HashMap<String, String> { fn capture_env(var_names: Option<String>, config: &config::Session) -> HashMap<String, String> {
let var_names = var_names let var_names = var_names
.or(config.cap_env.clone()) .or(config.cap_env.clone())
.unwrap_or(String::from("SHELL")); .unwrap_or(String::from("SHELL"));

View File

@@ -20,7 +20,7 @@ pub type Key = Option<Vec<u8>>;
#[allow(unused)] #[allow(unused)]
pub struct Config { pub struct Config {
server: Server, server: Server,
pub recording: Recording, pub session: Session,
pub playback: Playback, pub playback: Playback,
pub notifications: Notifications, pub notifications: Notifications,
} }
@@ -33,7 +33,7 @@ pub struct Server {
#[derive(Debug, Clone, Deserialize, Default)] #[derive(Debug, Clone, Deserialize, Default)]
#[allow(unused)] #[allow(unused)]
pub struct Recording { pub struct Session {
pub command: Option<String>, pub command: Option<String>,
pub cap_input: bool, pub cap_input: bool,
pub cap_env: Option<String>, pub cap_env: Option<String>,
@@ -65,7 +65,7 @@ impl Config {
let mut config = config::Config::builder() let mut config = config::Config::builder()
.set_default("server.url", None::<Option<String>>)? .set_default("server.url", None::<Option<String>>)?
.set_default("playback.speed", None::<Option<f64>>)? .set_default("playback.speed", None::<Option<f64>>)?
.set_default("recording.cap_input", false)? .set_default("session.cap_input", false)?
.set_default("notifications.enabled", true)? .set_default("notifications.enabled", true)?
.add_source(File::with_name("/etc/asciinema/config.toml").required(false)) .add_source(File::with_name("/etc/asciinema/config.toml").required(false))
.add_source(File::with_name(&user_defaults_path()?.to_string_lossy()).required(false)) .add_source(File::with_name(&user_defaults_path()?.to_string_lossy()).required(false))
@@ -116,7 +116,7 @@ impl Config {
} }
} }
impl Recording { impl Session {
pub fn prefix_key(&self) -> Result<Option<Key>> { pub fn prefix_key(&self) -> Result<Option<Key>> {
self.prefix_key.as_ref().map(parse_key).transpose() self.prefix_key.as_ref().map(parse_key).transpose()
} }