More explicit option names for input/env capture

This commit is contained in:
Marcin Kulik
2025-08-29 21:26:14 +02:00
parent e2584a808c
commit d962a1e22d
4 changed files with 22 additions and 22 deletions

View File

@@ -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 session.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.capture_input.
#[arg( #[arg(
long, long,
short = 'I', short = 'I',
@@ -135,16 +135,16 @@ pub struct Record {
help = "Enable input (keyboard) capture", help = "Enable input (keyboard) capture",
long_help long_help
)] )]
pub cap_input: bool, pub capture_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 session.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.capture_env.
#[arg( #[arg(
long, long,
value_name = "VARS", value_name = "VARS",
help = "Comma-separated list of environment variables to capture [default: SHELL]", help = "Comma-separated list of environment variables to capture [default: SHELL]",
long_help long_help
)] )]
pub cap_env: Option<String>, pub capture_env: Option<String>,
/// Append the new session to an existing recording file instead of creating a new one. This allows you to continue a previous recording session. The timing will be adjusted to maintain continuity from where the previous recording ended. Cannot be used together with --overwrite. /// Append the new session to an existing recording file instead of creating a new one. This allows you to continue a previous recording session. The timing will be adjusted to maintain continuity from where the previous recording ended. Cannot be used together with --overwrite.
#[arg(short, long, help = "Append to an existing recording file", long_help)] #[arg(short, long, help = "Append to an existing recording file", long_help)]
@@ -266,18 +266,18 @@ 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 session.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.capture_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 capture_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 session.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.capture_env.
#[arg( #[arg(
long, long,
value_name = "VARS", value_name = "VARS",
help = "Comma-separated list of environment variables to capture [default: SHELL]", help = "Comma-separated list of environment variables to capture [default: SHELL]",
long_help long_help
)] )]
pub cap_env: Option<String>, pub capture_env: Option<String>,
/// Set a descriptive title for the streaming session. This title is displayed to viewers (when doing remote streaming with --remote). For example: --title "Building a REST API". If the server has stream recording enabled then the title will be included in the recording file created on the server side. /// Set a descriptive title for the streaming session. This title is displayed to viewers (when doing remote streaming with --remote). For example: --title "Building a REST API". If the server has stream recording enabled then the title will be included in the recording file created on the server side.
#[arg(short, long, help = "Title of the session", long_help)] #[arg(short, long, help = "Title of the session", long_help)]
@@ -349,18 +349,18 @@ 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 session.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.capture_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 capture_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 session.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.capture_env.
#[arg( #[arg(
long, long,
value_name = "VARS", value_name = "VARS",
help = "Comma-separated list of environment variables to capture [default: SHELL]", help = "Comma-separated list of environment variables to capture [default: SHELL]",
long_help long_help
)] )]
pub cap_env: Option<String>, pub capture_env: Option<String>,
/// Append the new session to an existing recording file instead of creating a new one. This allows you to continue a previous recording session. The timing will be adjusted to maintain continuity from where the previous recording ended. Cannot be used together with --overwrite. Only applies when --output-file is specified. /// Append the new session to an existing recording file instead of creating a new one. This allows you to continue a previous recording session. The timing will be adjusted to maintain continuity from where the previous recording ended. Cannot be used together with --overwrite. Only applies when --output-file is specified.
#[arg(short, long, help = "Append to an existing recording file", long_help)] #[arg(short, long, help = "Append to an existing recording file", long_help)]

View File

@@ -131,7 +131,7 @@ impl cli::Session {
command, command,
extra_env, extra_env,
tty.as_mut(), tty.as_mut(),
self.cap_input || config.session.cap_input, self.capture_input || config.session.capture_input,
outputs, outputs,
keys, keys,
notifier, notifier,
@@ -171,7 +171,7 @@ impl cli::Session {
idle_time_limit: self.idle_time_limit.or(config.idle_time_limit), idle_time_limit: self.idle_time_limit.or(config.idle_time_limit),
command: self.get_command(config), command: self.get_command(config),
title: self.title.clone(), title: self.title.clone(),
env: capture_env(self.cap_env.clone(), config), env: capture_env(self.capture_env.clone(), config),
}) })
} }
@@ -458,7 +458,7 @@ fn get_key_bindings(config: &config::Session) -> Result<KeyBindings> {
fn capture_env(var_names: Option<String>, config: &config::Session) -> 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.capture_env.clone())
.unwrap_or(String::from("SHELL")); .unwrap_or(String::from("SHELL"));
let vars = var_names.split(',').collect::<HashSet<_>>(); let vars = var_names.split(',').collect::<HashSet<_>>();

View File

@@ -35,8 +35,8 @@ pub struct Server {
#[allow(unused)] #[allow(unused)]
pub struct Session { pub struct Session {
pub command: Option<String>, pub command: Option<String>,
pub cap_input: bool, pub capture_input: bool,
pub cap_env: Option<String>, pub capture_env: Option<String>,
pub idle_time_limit: Option<f64>, pub idle_time_limit: Option<f64>,
pub prefix_key: Option<String>, pub prefix_key: Option<String>,
pub pause_key: Option<String>, pub pause_key: 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("session.cap_input", false)? .set_default("session.capture_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))

View File

@@ -43,12 +43,12 @@ fn main() -> ExitCode {
Commands::Record(cmd) => { Commands::Record(cmd) => {
let cmd = Session { let cmd = Session {
output_file: Some(cmd.file), output_file: Some(cmd.file),
cap_input: cmd.cap_input, capture_input: cmd.capture_input,
append: cmd.append, append: cmd.append,
output_format: cmd.output_format, output_format: cmd.output_format,
overwrite: cmd.overwrite, overwrite: cmd.overwrite,
command: cmd.command, command: cmd.command,
cap_env: cmd.cap_env, capture_env: cmd.capture_env,
title: cmd.title, title: cmd.title,
idle_time_limit: cmd.idle_time_limit, idle_time_limit: cmd.idle_time_limit,
headless: cmd.headless, headless: cmd.headless,
@@ -67,12 +67,12 @@ fn main() -> ExitCode {
Commands::Stream(cmd) => { Commands::Stream(cmd) => {
let cmd = Session { let cmd = Session {
output_file: None, output_file: None,
cap_input: cmd.cap_input, capture_input: cmd.capture_input,
append: false, append: false,
output_format: None, output_format: None,
overwrite: false, overwrite: false,
command: cmd.command, command: cmd.command,
cap_env: cmd.cap_env, capture_env: cmd.capture_env,
title: cmd.title, title: cmd.title,
idle_time_limit: None, idle_time_limit: None,
headless: cmd.headless, headless: cmd.headless,