From 9d943b45174e11e1e33dabd2053cc8aaa8373a0d Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Fri, 29 Aug 2025 16:07:29 +0200 Subject: [PATCH] Rename options related to input and env var capture --- src/cli.rs | 40 +++++++++++++++------------------------- src/cmd/session.rs | 6 +++--- src/config.rs | 6 +++--- src/main.rs | 8 ++++---- 4 files changed, 25 insertions(+), 35 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 08d9567..8741fa8 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -127,24 +127,24 @@ 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 recording.rec_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 recording.cap_input. #[arg( long, short = 'I', alias = "stdin", - help = "Enable input (keyboard) recording", + help = "Enable input (keyboard) capture", long_help )] - pub rec_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.rec_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 recording.cap_env. #[arg( long, value_name = "VARS", help = "Comma-separated list of environment variables to capture [default: SHELL]", long_help )] - pub rec_env: Option, + pub cap_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,23 +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 recording.rec_input. - #[arg( - long, - short = 'I', - help = "Enable input (keyboard) recording", - long_help - )] - pub rec_input: bool, + /// 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. + #[arg(long, short = 'I', help = "Enable input (keyboard) capture", long_help)] + 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.rec_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 recording.cap_env. #[arg( long, value_name = "VARS", help = "Comma-separated list of environment variables to capture [default: SHELL]", long_help )] - pub rec_env: Option, + pub cap_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)] @@ -354,23 +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 recording.rec_input. - #[arg( - long, - short = 'I', - help = "Enable input (keyboard) recording", - long_help - )] - pub rec_input: bool, + /// 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. + #[arg(long, short = 'I', help = "Enable input (keyboard) capture", long_help)] + 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.rec_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 recording.cap_env. #[arg( long, value_name = "VARS", help = "Comma-separated list of environment variables to capture [default: SHELL]", long_help )] - pub rec_env: Option, + pub cap_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 a678d5f..29298cf 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.rec_input || config.recording.rec_input, + self.cap_input || config.recording.cap_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.rec_env.clone(), config), + env: capture_env(self.cap_env.clone(), config), }) } @@ -458,7 +458,7 @@ fn get_key_bindings(config: &config::Recording) -> Result { fn capture_env(var_names: Option, config: &config::Recording) -> HashMap { let var_names = var_names - .or(config.rec_env.clone()) + .or(config.cap_env.clone()) .unwrap_or(String::from("SHELL")); let vars = var_names.split(',').collect::>(); diff --git a/src/config.rs b/src/config.rs index 353403c..53e9b41 100644 --- a/src/config.rs +++ b/src/config.rs @@ -35,8 +35,8 @@ pub struct Server { #[allow(unused)] pub struct Recording { pub command: Option, - pub rec_input: bool, - pub rec_env: Option, + pub cap_input: bool, + pub cap_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("recording.rec_input", false)? + .set_default("recording.cap_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 7b1bf24..89840f3 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), - rec_input: cmd.rec_input, + cap_input: cmd.cap_input, append: cmd.append, output_format: cmd.output_format, overwrite: cmd.overwrite, command: cmd.command, - rec_env: cmd.rec_env, + cap_env: cmd.cap_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, - rec_input: cmd.rec_input, + cap_input: cmd.cap_input, append: false, output_format: None, overwrite: false, command: cmd.command, - rec_env: cmd.rec_env, + cap_env: cmd.cap_env, title: cmd.title, idle_time_limit: None, headless: cmd.headless,