From d962a1e22d975a02e62edacc6dd7c229aa7f8fba Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Fri, 29 Aug 2025 21:26:14 +0200 Subject: [PATCH] More explicit option names for input/env capture --- src/cli.rs | 24 ++++++++++++------------ src/cmd/session.rs | 6 +++--- src/config.rs | 6 +++--- src/main.rs | 8 ++++---- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index a640040..9eb56b5 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -127,7 +127,7 @@ pub struct Record { )] pub command: Option, - /// 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( long, short = 'I', @@ -135,16 +135,16 @@ pub struct Record { 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 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( long, value_name = "VARS", help = "Comma-separated list of environment variables to capture [default: SHELL]", long_help )] - pub cap_env: Option, + pub capture_env: Option, /// 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)] @@ -266,18 +266,18 @@ pub struct Stream { )] pub command: Option, - /// 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)] - 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( long, value_name = "VARS", help = "Comma-separated list of environment variables to capture [default: SHELL]", long_help )] - pub cap_env: Option, + pub capture_env: Option, /// 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)] @@ -349,18 +349,18 @@ pub struct Session { )] pub command: Option, - /// 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)] - 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( long, value_name = "VARS", help = "Comma-separated list of environment variables to capture [default: SHELL]", long_help )] - pub cap_env: Option, + pub capture_env: Option, /// 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)] diff --git a/src/cmd/session.rs b/src/cmd/session.rs index fe2369f..fc0738a 100644 --- a/src/cmd/session.rs +++ b/src/cmd/session.rs @@ -131,7 +131,7 @@ impl cli::Session { command, extra_env, tty.as_mut(), - self.cap_input || config.session.cap_input, + self.capture_input || config.session.capture_input, outputs, keys, notifier, @@ -171,7 +171,7 @@ impl cli::Session { idle_time_limit: self.idle_time_limit.or(config.idle_time_limit), command: self.get_command(config), 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 { fn capture_env(var_names: Option, config: &config::Session) -> HashMap { let var_names = var_names - .or(config.cap_env.clone()) + .or(config.capture_env.clone()) .unwrap_or(String::from("SHELL")); let vars = var_names.split(',').collect::>(); diff --git a/src/config.rs b/src/config.rs index 6d0cf85..6564cb8 100644 --- a/src/config.rs +++ b/src/config.rs @@ -35,8 +35,8 @@ pub struct Server { #[allow(unused)] pub struct Session { pub command: Option, - pub cap_input: bool, - pub cap_env: Option, + pub capture_input: bool, + pub capture_env: Option, pub idle_time_limit: Option, pub prefix_key: Option, pub pause_key: Option, @@ -65,7 +65,7 @@ impl Config { let mut config = config::Config::builder() .set_default("server.url", None::>)? .set_default("playback.speed", None::>)? - .set_default("session.cap_input", false)? + .set_default("session.capture_input", false)? .set_default("notifications.enabled", true)? .add_source(File::with_name("/etc/asciinema/config.toml").required(false)) .add_source(File::with_name(&user_defaults_path()?.to_string_lossy()).required(false)) diff --git a/src/main.rs b/src/main.rs index 89840f3..744aa8a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,12 +43,12 @@ fn main() -> ExitCode { Commands::Record(cmd) => { let cmd = Session { output_file: Some(cmd.file), - cap_input: cmd.cap_input, + capture_input: cmd.capture_input, append: cmd.append, output_format: cmd.output_format, overwrite: cmd.overwrite, command: cmd.command, - cap_env: cmd.cap_env, + capture_env: cmd.capture_env, title: cmd.title, idle_time_limit: cmd.idle_time_limit, headless: cmd.headless, @@ -67,12 +67,12 @@ fn main() -> ExitCode { Commands::Stream(cmd) => { let cmd = Session { output_file: None, - cap_input: cmd.cap_input, + capture_input: cmd.capture_input, append: false, output_format: None, overwrite: false, command: cmd.command, - cap_env: cmd.cap_env, + capture_env: cmd.capture_env, title: cmd.title, idle_time_limit: None, headless: cmd.headless,