mirror of
https://github.com/asciinema/asciinema.git
synced 2025-12-16 11:48:13 +01:00
Make option names more clear
This commit is contained in:
118
src/cli.rs
118
src/cli.rs
@@ -14,7 +14,7 @@ pub struct Cli {
|
|||||||
pub command: Commands,
|
pub command: Commands,
|
||||||
|
|
||||||
/// asciinema server URL
|
/// asciinema server URL
|
||||||
#[arg(long, global = true, display_order = 100)]
|
#[arg(long, global = true, display_order = 100, value_name = "URL")]
|
||||||
pub server_url: Option<String>,
|
pub server_url: Option<String>,
|
||||||
|
|
||||||
/// Quiet mode, i.e. suppress diagnostic messages
|
/// Quiet mode, i.e. suppress diagnostic messages
|
||||||
@@ -52,39 +52,36 @@ pub enum Commands {
|
|||||||
#[derive(Debug, Args)]
|
#[derive(Debug, Args)]
|
||||||
pub struct Record {
|
pub struct Record {
|
||||||
/// Output path - either a file or a directory path
|
/// Output path - either a file or a directory path
|
||||||
pub path: String,
|
pub output_path: String,
|
||||||
|
|
||||||
/// Enable input recording
|
/// Output file format [default: asciicast-v3]
|
||||||
#[arg(long, short = 'I', alias = "stdin")]
|
#[arg(short = 'f', long, value_enum, value_name = "FORMAT")]
|
||||||
pub input: bool,
|
pub output_format: Option<Format>,
|
||||||
|
|
||||||
/// Append to an existing recording file
|
|
||||||
#[arg(short, long)]
|
|
||||||
pub append: bool,
|
|
||||||
|
|
||||||
/// Recording file format [default: asciicast-v3]
|
|
||||||
#[arg(short, long, value_enum)]
|
|
||||||
pub format: Option<Format>,
|
|
||||||
|
|
||||||
#[arg(long, hide = true)]
|
|
||||||
pub raw: bool,
|
|
||||||
|
|
||||||
/// Overwrite target file if it already exists
|
|
||||||
#[arg(long, conflicts_with = "append")]
|
|
||||||
pub overwrite: bool,
|
|
||||||
|
|
||||||
/// Command to start in the session [default: $SHELL]
|
/// Command to start in the session [default: $SHELL]
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
pub command: Option<String>,
|
pub command: Option<String>,
|
||||||
|
|
||||||
|
/// Enable input (keys) recording
|
||||||
|
#[arg(long, short = 'I', alias = "stdin")]
|
||||||
|
pub rec_input: bool,
|
||||||
|
|
||||||
|
/// List of env vars to capture [default: TERM,SHELL]
|
||||||
|
#[arg(long, value_name = "VARS")]
|
||||||
|
pub rec_env: Option<String>,
|
||||||
|
|
||||||
|
/// Append to an existing recording file
|
||||||
|
#[arg(short, long)]
|
||||||
|
pub append: bool,
|
||||||
|
|
||||||
|
/// Overwrite output file if it already exists
|
||||||
|
#[arg(long, conflicts_with = "append")]
|
||||||
|
pub overwrite: bool,
|
||||||
|
|
||||||
/// Filename template, used when recording to a directory
|
/// Filename template, used when recording to a directory
|
||||||
#[arg(long, value_name = "TEMPLATE")]
|
#[arg(long, value_name = "TEMPLATE")]
|
||||||
pub filename: Option<String>,
|
pub filename: Option<String>,
|
||||||
|
|
||||||
/// List of env vars to save [default: TERM,SHELL]
|
|
||||||
#[arg(long)]
|
|
||||||
pub env: Option<String>,
|
|
||||||
|
|
||||||
/// Title of the recording
|
/// Title of the recording
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
pub title: Option<String>,
|
pub title: Option<String>,
|
||||||
@@ -93,7 +90,7 @@ pub struct Record {
|
|||||||
#[arg(short, long, value_name = "SECS")]
|
#[arg(short, long, value_name = "SECS")]
|
||||||
pub idle_time_limit: Option<f64>,
|
pub idle_time_limit: Option<f64>,
|
||||||
|
|
||||||
/// Use headless mode - don't use TTY for input/output
|
/// Headless mode, i.e. don't use TTY for input/output
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub headless: bool,
|
pub headless: bool,
|
||||||
|
|
||||||
@@ -106,6 +103,9 @@ pub struct Record {
|
|||||||
|
|
||||||
#[arg(long, hide = true)]
|
#[arg(long, hide = true)]
|
||||||
pub rows: Option<u16>,
|
pub rows: Option<u16>,
|
||||||
|
|
||||||
|
#[arg(long, hide = true)]
|
||||||
|
pub raw: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Args)]
|
#[derive(Debug, Args)]
|
||||||
@@ -132,14 +132,18 @@ pub struct Play {
|
|||||||
|
|
||||||
#[derive(Debug, Args)]
|
#[derive(Debug, Args)]
|
||||||
pub struct Stream {
|
pub struct Stream {
|
||||||
/// Enable input capture
|
/// Command to start in the session [default: $SHELL]
|
||||||
#[arg(long, short = 'I', alias = "stdin")]
|
|
||||||
pub input: bool,
|
|
||||||
|
|
||||||
/// Command to stream [default: $SHELL]
|
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
pub command: Option<String>,
|
pub command: Option<String>,
|
||||||
|
|
||||||
|
/// Enable input (keys) recording
|
||||||
|
#[arg(long, short = 'I')]
|
||||||
|
pub rec_input: bool,
|
||||||
|
|
||||||
|
/// List of env vars to capture [default: TERM,SHELL]
|
||||||
|
#[arg(long, value_name = "VARS")]
|
||||||
|
pub rec_env: Option<String>,
|
||||||
|
|
||||||
/// Serve the stream with the built-in HTTP server
|
/// Serve the stream with the built-in HTTP server
|
||||||
#[arg(short, long, value_name = "IP:PORT", default_missing_value = DEFAULT_LISTEN_ADDR, num_args = 0..=1)]
|
#[arg(short, long, value_name = "IP:PORT", default_missing_value = DEFAULT_LISTEN_ADDR, num_args = 0..=1)]
|
||||||
pub serve: Option<SocketAddr>,
|
pub serve: Option<SocketAddr>,
|
||||||
@@ -148,11 +152,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)]
|
#[arg(short, long, value_name = "STREAM-ID|WS-URL", default_missing_value = "", num_args = 0..=1, value_parser = validate_forward_target)]
|
||||||
pub relay: Option<RelayTarget>,
|
pub relay: Option<RelayTarget>,
|
||||||
|
|
||||||
/// List of env vars to save [default: TERM,SHELL]
|
/// Headless mode, i.e. don't use TTY for input/output
|
||||||
#[arg(long)]
|
|
||||||
pub env: Option<String>,
|
|
||||||
|
|
||||||
/// Use headless mode - don't use TTY for input/output
|
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub headless: bool,
|
pub headless: bool,
|
||||||
|
|
||||||
@@ -161,44 +161,44 @@ pub struct Stream {
|
|||||||
pub tty_size: Option<(Option<u16>, Option<u16>)>,
|
pub tty_size: Option<(Option<u16>, Option<u16>)>,
|
||||||
|
|
||||||
/// Log file path
|
/// Log file path
|
||||||
#[arg(long)]
|
#[arg(long, value_name = "PATH")]
|
||||||
pub log_file: Option<PathBuf>,
|
pub log_file: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Args)]
|
#[derive(Debug, Args)]
|
||||||
pub struct Session {
|
pub struct Session {
|
||||||
/// Output path - either a file or a directory path
|
/// Output path - either a file or a directory path
|
||||||
#[arg(short, long)]
|
#[arg(short, long, value_name = "PATH")]
|
||||||
pub output: Option<String>,
|
pub output_file: Option<String>,
|
||||||
|
|
||||||
/// Enable input recording
|
/// Output file format [default: asciicast-v3]
|
||||||
#[arg(long, short = 'I', alias = "stdin")]
|
#[arg(short = 'f', long, value_enum, value_name = "FORMAT")]
|
||||||
pub input: bool,
|
pub output_format: Option<Format>,
|
||||||
|
|
||||||
/// Append to an existing recording file
|
|
||||||
#[arg(short, long)]
|
|
||||||
pub append: bool,
|
|
||||||
|
|
||||||
/// Recording file format [default: asciicast-v3]
|
|
||||||
#[arg(short, long, value_enum)]
|
|
||||||
pub format: Option<Format>,
|
|
||||||
|
|
||||||
/// Overwrite target file if it already exists
|
|
||||||
#[arg(long, conflicts_with = "append")]
|
|
||||||
pub overwrite: bool,
|
|
||||||
|
|
||||||
/// Command to start in the session [default: $SHELL]
|
/// Command to start in the session [default: $SHELL]
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
pub command: Option<String>,
|
pub command: Option<String>,
|
||||||
|
|
||||||
|
/// Enable input (keys) recording
|
||||||
|
#[arg(long, short = 'I')]
|
||||||
|
pub rec_input: bool,
|
||||||
|
|
||||||
|
/// List of env vars to capture [default: TERM,SHELL]
|
||||||
|
#[arg(long, value_name = "VARS")]
|
||||||
|
pub rec_env: Option<String>,
|
||||||
|
|
||||||
|
/// Append to an existing recording file
|
||||||
|
#[arg(short, long)]
|
||||||
|
pub append: bool,
|
||||||
|
|
||||||
|
/// Overwrite output file if it already exists
|
||||||
|
#[arg(long, conflicts_with = "append")]
|
||||||
|
pub overwrite: bool,
|
||||||
|
|
||||||
/// Filename template, used when recording to a directory
|
/// Filename template, used when recording to a directory
|
||||||
#[arg(long, value_name = "TEMPLATE")]
|
#[arg(long, value_name = "TEMPLATE")]
|
||||||
pub filename: Option<String>,
|
pub filename: Option<String>,
|
||||||
|
|
||||||
/// List of env vars to save [default: TERM,SHELL]
|
|
||||||
#[arg(long)]
|
|
||||||
pub env: Option<String>,
|
|
||||||
|
|
||||||
/// Title of the recording
|
/// Title of the recording
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
pub title: Option<String>,
|
pub title: Option<String>,
|
||||||
@@ -207,7 +207,7 @@ pub struct Session {
|
|||||||
#[arg(short, long, value_name = "SECS")]
|
#[arg(short, long, value_name = "SECS")]
|
||||||
pub idle_time_limit: Option<f64>,
|
pub idle_time_limit: Option<f64>,
|
||||||
|
|
||||||
/// Use headless mode - don't use TTY for input/output
|
/// Headless mode, i.e. don't use TTY for input/output
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub headless: bool,
|
pub headless: bool,
|
||||||
|
|
||||||
@@ -224,7 +224,7 @@ pub struct Session {
|
|||||||
pub relay: Option<RelayTarget>,
|
pub relay: Option<RelayTarget>,
|
||||||
|
|
||||||
/// Log file path
|
/// Log file path
|
||||||
#[arg(long)]
|
#[arg(long, value_name = "PATH")]
|
||||||
pub log_file: Option<PathBuf>,
|
pub log_file: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,13 +42,13 @@ impl cli::Session {
|
|||||||
let command = self.get_command(cmd_config);
|
let command = self.get_command(cmd_config);
|
||||||
let keys = get_key_bindings(cmd_config)?;
|
let keys = get_key_bindings(cmd_config)?;
|
||||||
let notifier = notifier::threaded(get_notifier(config));
|
let notifier = notifier::threaded(get_notifier(config));
|
||||||
let record_input = self.input || cmd_config.input;
|
let record_input = self.rec_input || cmd_config.rec_input;
|
||||||
let term_type = self.get_term_type();
|
let term_type = self.get_term_type();
|
||||||
let term_version = self.get_term_version()?;
|
let term_version = self.get_term_version()?;
|
||||||
let env = capture_env(self.env.clone(), cmd_config);
|
let env = capture_env(self.rec_env.clone(), cmd_config);
|
||||||
|
|
||||||
let path = self
|
let path = self
|
||||||
.output
|
.output_file
|
||||||
.take()
|
.take()
|
||||||
.map(|path| self.ensure_filename(path, cmd_config))
|
.map(|path| self.ensure_filename(path, cmd_config))
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
@@ -232,7 +232,7 @@ impl cli::Session {
|
|||||||
env: &HashMap<String, String>,
|
env: &HashMap<String, String>,
|
||||||
notifier: N,
|
notifier: N,
|
||||||
) -> Result<FileWriterStarter> {
|
) -> Result<FileWriterStarter> {
|
||||||
let format = self.format.unwrap_or_else(|| {
|
let format = self.output_format.unwrap_or_else(|| {
|
||||||
if path.to_lowercase().ends_with(".txt") {
|
if path.to_lowercase().ends_with(".txt") {
|
||||||
Format::Txt
|
Format::Txt
|
||||||
} else {
|
} else {
|
||||||
@@ -496,7 +496,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.env.clone())
|
.or(config.rec_env.clone())
|
||||||
.unwrap_or(String::from("TERM,SHELL"));
|
.unwrap_or(String::from("TERM,SHELL"));
|
||||||
|
|
||||||
let vars = var_names.split(',').collect::<HashSet<_>>();
|
let vars = var_names.split(',').collect::<HashSet<_>>();
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ pub struct Cmd {
|
|||||||
pub struct Session {
|
pub struct Session {
|
||||||
pub command: Option<String>,
|
pub command: Option<String>,
|
||||||
pub filename: String,
|
pub filename: String,
|
||||||
pub input: bool,
|
pub rec_input: bool,
|
||||||
pub env: Option<String>,
|
pub rec_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>,
|
||||||
@@ -55,8 +55,8 @@ pub struct Session {
|
|||||||
pub struct Rec {
|
pub struct Rec {
|
||||||
pub command: Option<String>,
|
pub command: Option<String>,
|
||||||
pub filename: String,
|
pub filename: String,
|
||||||
pub input: bool,
|
pub rec_input: bool,
|
||||||
pub env: Option<String>,
|
pub rec_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>,
|
||||||
@@ -77,8 +77,8 @@ pub struct Play {
|
|||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub struct Stream {
|
pub struct Stream {
|
||||||
pub command: Option<String>,
|
pub command: Option<String>,
|
||||||
pub input: bool,
|
pub rec_input: bool,
|
||||||
pub env: Option<String>,
|
pub rec_env: Option<String>,
|
||||||
pub prefix_key: Option<String>,
|
pub prefix_key: Option<String>,
|
||||||
pub pause_key: Option<String>,
|
pub pause_key: Option<String>,
|
||||||
pub add_marker_key: Option<String>,
|
pub add_marker_key: Option<String>,
|
||||||
@@ -95,11 +95,11 @@ impl Config {
|
|||||||
pub fn new(server_url: Option<String>) -> Result<Self> {
|
pub fn new(server_url: Option<String>) -> Result<Self> {
|
||||||
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("cmd.rec.input", false)?
|
.set_default("cmd.rec.rec_input", false)?
|
||||||
.set_default("cmd.rec.filename", DEFAULT_REC_FILENAME)?
|
.set_default("cmd.rec.filename", DEFAULT_REC_FILENAME)?
|
||||||
.set_default("cmd.play.speed", None::<Option<f64>>)?
|
.set_default("cmd.play.speed", None::<Option<f64>>)?
|
||||||
.set_default("cmd.stream.input", false)?
|
.set_default("cmd.stream.rec_input", false)?
|
||||||
.set_default("cmd.session.input", false)?
|
.set_default("cmd.session.rec_input", false)?
|
||||||
.set_default("cmd.session.filename", DEFAULT_REC_FILENAME)?
|
.set_default("cmd.session.filename", DEFAULT_REC_FILENAME)?
|
||||||
.set_default("notifications.enabled", true)?
|
.set_default("notifications.enabled", true)?
|
||||||
.add_source(config::File::with_name("/etc/asciinema/config.toml").required(false))
|
.add_source(config::File::with_name("/etc/asciinema/config.toml").required(false))
|
||||||
@@ -155,8 +155,8 @@ impl Config {
|
|||||||
Session {
|
Session {
|
||||||
command: self.cmd.rec.command.clone(),
|
command: self.cmd.rec.command.clone(),
|
||||||
filename: self.cmd.rec.filename.clone(),
|
filename: self.cmd.rec.filename.clone(),
|
||||||
input: self.cmd.rec.input,
|
rec_input: self.cmd.rec.rec_input,
|
||||||
env: self.cmd.rec.env.clone(),
|
rec_env: self.cmd.rec.rec_env.clone(),
|
||||||
idle_time_limit: self.cmd.rec.idle_time_limit,
|
idle_time_limit: self.cmd.rec.idle_time_limit,
|
||||||
prefix_key: self.cmd.rec.prefix_key.clone(),
|
prefix_key: self.cmd.rec.prefix_key.clone(),
|
||||||
pause_key: self.cmd.rec.pause_key.clone(),
|
pause_key: self.cmd.rec.pause_key.clone(),
|
||||||
@@ -168,8 +168,8 @@ impl Config {
|
|||||||
Session {
|
Session {
|
||||||
command: self.cmd.stream.command.clone(),
|
command: self.cmd.stream.command.clone(),
|
||||||
filename: "".to_string(),
|
filename: "".to_string(),
|
||||||
input: self.cmd.stream.input,
|
rec_input: self.cmd.stream.rec_input,
|
||||||
env: self.cmd.stream.env.clone(),
|
rec_env: self.cmd.stream.rec_env.clone(),
|
||||||
idle_time_limit: None,
|
idle_time_limit: None,
|
||||||
prefix_key: self.cmd.stream.prefix_key.clone(),
|
prefix_key: self.cmd.stream.prefix_key.clone(),
|
||||||
pause_key: self.cmd.stream.pause_key.clone(),
|
pause_key: self.cmd.stream.pause_key.clone(),
|
||||||
|
|||||||
16
src/main.rs
16
src/main.rs
@@ -38,14 +38,14 @@ fn main() -> anyhow::Result<()> {
|
|||||||
match cli.command {
|
match cli.command {
|
||||||
Commands::Rec(cmd) => {
|
Commands::Rec(cmd) => {
|
||||||
let cmd = Session {
|
let cmd = Session {
|
||||||
output: Some(cmd.path),
|
output_file: Some(cmd.output_path),
|
||||||
input: cmd.input,
|
rec_input: cmd.rec_input,
|
||||||
append: cmd.append,
|
append: cmd.append,
|
||||||
format: cmd.format,
|
output_format: cmd.output_format,
|
||||||
overwrite: cmd.overwrite,
|
overwrite: cmd.overwrite,
|
||||||
command: cmd.command,
|
command: cmd.command,
|
||||||
filename: cmd.filename,
|
filename: cmd.filename,
|
||||||
env: cmd.env,
|
rec_env: cmd.rec_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,
|
||||||
@@ -60,14 +60,14 @@ fn main() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
Commands::Stream(stream) => {
|
Commands::Stream(stream) => {
|
||||||
let cmd = Session {
|
let cmd = Session {
|
||||||
output: None,
|
output_file: None,
|
||||||
input: stream.input,
|
rec_input: stream.rec_input,
|
||||||
append: false,
|
append: false,
|
||||||
format: None,
|
output_format: None,
|
||||||
overwrite: false,
|
overwrite: false,
|
||||||
command: stream.command,
|
command: stream.command,
|
||||||
filename: None,
|
filename: None,
|
||||||
env: stream.env,
|
rec_env: stream.rec_env,
|
||||||
title: None,
|
title: None,
|
||||||
idle_time_limit: None,
|
idle_time_limit: None,
|
||||||
headless: stream.headless,
|
headless: stream.headless,
|
||||||
|
|||||||
Reference in New Issue
Block a user