mirror of
https://github.com/asciinema/asciinema.git
synced 2025-12-16 03:38:03 +01:00
More tweaks to rec/stream/session cmdline options
This commit is contained in:
42
src/cli.rs
42
src/cli.rs
@@ -51,7 +51,7 @@ 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 file path
|
||||||
pub output_path: String,
|
pub output_path: String,
|
||||||
|
|
||||||
/// Output file format [default: asciicast-v3]
|
/// Output file format [default: asciicast-v3]
|
||||||
@@ -66,7 +66,7 @@ pub struct Record {
|
|||||||
#[arg(long, short = 'I', alias = "stdin")]
|
#[arg(long, short = 'I', alias = "stdin")]
|
||||||
pub rec_input: bool,
|
pub rec_input: bool,
|
||||||
|
|
||||||
/// List of env vars to capture [default: SHELL]
|
/// Comma-separated list of env vars to capture [default: SHELL]
|
||||||
#[arg(long, value_name = "VARS")]
|
#[arg(long, value_name = "VARS")]
|
||||||
pub rec_env: Option<String>,
|
pub rec_env: Option<String>,
|
||||||
|
|
||||||
@@ -128,6 +128,14 @@ pub struct Play {
|
|||||||
|
|
||||||
#[derive(Debug, Args)]
|
#[derive(Debug, Args)]
|
||||||
pub struct Stream {
|
pub struct Stream {
|
||||||
|
/// Stream the session via a local HTTP server
|
||||||
|
#[arg(short, long, value_name = "IP:PORT", default_missing_value = DEFAULT_LISTEN_ADDR, num_args = 0..=1)]
|
||||||
|
pub local: Option<SocketAddr>,
|
||||||
|
|
||||||
|
/// Stream the session via a remote asciinema server
|
||||||
|
#[arg(short, long, value_name = "STREAM-ID|WS-URL", default_missing_value = "", num_args = 0..=1, value_parser = validate_forward_target)]
|
||||||
|
pub remote: Option<RelayTarget>,
|
||||||
|
|
||||||
/// 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>,
|
||||||
@@ -136,18 +144,10 @@ pub struct Stream {
|
|||||||
#[arg(long, short = 'I')]
|
#[arg(long, short = 'I')]
|
||||||
pub rec_input: bool,
|
pub rec_input: bool,
|
||||||
|
|
||||||
/// List of env vars to capture [default: SHELL]
|
/// Comma-separated list of env vars to capture [default: SHELL]
|
||||||
#[arg(long, value_name = "VARS")]
|
#[arg(long, value_name = "VARS")]
|
||||||
pub rec_env: Option<String>,
|
pub rec_env: Option<String>,
|
||||||
|
|
||||||
/// 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)]
|
|
||||||
pub serve: Option<SocketAddr>,
|
|
||||||
|
|
||||||
/// Relay the stream via an asciinema server
|
|
||||||
#[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>,
|
|
||||||
|
|
||||||
/// Headless mode, i.e. 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,
|
||||||
@@ -163,7 +163,7 @@ pub struct Stream {
|
|||||||
|
|
||||||
#[derive(Debug, Args)]
|
#[derive(Debug, Args)]
|
||||||
pub struct Session {
|
pub struct Session {
|
||||||
/// Output path - either a file or a directory path
|
/// Save the session in a file
|
||||||
#[arg(short, long, value_name = "PATH")]
|
#[arg(short, long, value_name = "PATH")]
|
||||||
pub output_file: Option<String>,
|
pub output_file: Option<String>,
|
||||||
|
|
||||||
@@ -171,6 +171,14 @@ pub struct Session {
|
|||||||
#[arg(short = 'f', long, value_enum, value_name = "FORMAT")]
|
#[arg(short = 'f', long, value_enum, value_name = "FORMAT")]
|
||||||
pub output_format: Option<Format>,
|
pub output_format: Option<Format>,
|
||||||
|
|
||||||
|
/// Stream the session via a local HTTP server
|
||||||
|
#[arg(short = 'l', long, value_name = "IP:PORT", default_missing_value = DEFAULT_LISTEN_ADDR, num_args = 0..=1)]
|
||||||
|
pub stream_local: Option<SocketAddr>,
|
||||||
|
|
||||||
|
/// Stream the session via a remote asciinema server
|
||||||
|
#[arg(short = 'r', long, value_name = "STREAM-ID|WS-URL", default_missing_value = "", num_args = 0..=1, value_parser = validate_forward_target)]
|
||||||
|
pub stream_remote: Option<RelayTarget>,
|
||||||
|
|
||||||
/// 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>,
|
||||||
@@ -179,7 +187,7 @@ pub struct Session {
|
|||||||
#[arg(long, short = 'I')]
|
#[arg(long, short = 'I')]
|
||||||
pub rec_input: bool,
|
pub rec_input: bool,
|
||||||
|
|
||||||
/// List of env vars to capture [default: SHELL]
|
/// Comma-separated list of env vars to capture [default: SHELL]
|
||||||
#[arg(long, value_name = "VARS")]
|
#[arg(long, value_name = "VARS")]
|
||||||
pub rec_env: Option<String>,
|
pub rec_env: Option<String>,
|
||||||
|
|
||||||
@@ -207,14 +215,6 @@ pub struct Session {
|
|||||||
#[arg(long, value_name = "COLSxROWS", value_parser = parse_tty_size)]
|
#[arg(long, value_name = "COLSxROWS", value_parser = parse_tty_size)]
|
||||||
pub tty_size: Option<(Option<u16>, Option<u16>)>,
|
pub tty_size: Option<(Option<u16>, Option<u16>)>,
|
||||||
|
|
||||||
/// Stream the session with the built-in HTTP server
|
|
||||||
#[arg(short, long, value_name = "IP:PORT", default_missing_value = DEFAULT_LISTEN_ADDR, num_args = 0..=1)]
|
|
||||||
pub serve: Option<SocketAddr>,
|
|
||||||
|
|
||||||
/// Stream the session via an asciinema server
|
|
||||||
#[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>,
|
|
||||||
|
|
||||||
/// Log file path
|
/// Log file path
|
||||||
#[arg(long, value_name = "PATH")]
|
#[arg(long, value_name = "PATH")]
|
||||||
pub log_file: Option<PathBuf>,
|
pub log_file: Option<PathBuf>,
|
||||||
|
|||||||
@@ -61,14 +61,14 @@ impl cli::Session {
|
|||||||
.transpose()?;
|
.transpose()?;
|
||||||
|
|
||||||
let mut listener = self
|
let mut listener = self
|
||||||
.serve
|
.stream_local
|
||||||
.take()
|
.take()
|
||||||
.map(TcpListener::bind)
|
.map(TcpListener::bind)
|
||||||
.transpose()
|
.transpose()
|
||||||
.context("cannot start listener")?;
|
.context("cannot start listener")?;
|
||||||
|
|
||||||
let mut relay = self
|
let mut relay = self
|
||||||
.relay
|
.stream_remote
|
||||||
.take()
|
.take()
|
||||||
.map(|target| get_relay(target, config, term_type, term_version, &env))
|
.map(|target| get_relay(target, config, term_type, term_version, &env))
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ fn main() -> anyhow::Result<()> {
|
|||||||
idle_time_limit: cmd.idle_time_limit,
|
idle_time_limit: cmd.idle_time_limit,
|
||||||
headless: cmd.headless,
|
headless: cmd.headless,
|
||||||
tty_size: cmd.tty_size,
|
tty_size: cmd.tty_size,
|
||||||
serve: None,
|
stream_local: None,
|
||||||
relay: None,
|
stream_remote: None,
|
||||||
log_file: None,
|
log_file: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -70,8 +70,8 @@ fn main() -> anyhow::Result<()> {
|
|||||||
idle_time_limit: None,
|
idle_time_limit: None,
|
||||||
headless: stream.headless,
|
headless: stream.headless,
|
||||||
tty_size: stream.tty_size,
|
tty_size: stream.tty_size,
|
||||||
serve: stream.serve,
|
stream_local: stream.local,
|
||||||
relay: stream.relay,
|
stream_remote: stream.remote,
|
||||||
log_file: stream.log_file,
|
log_file: stream.log_file,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user