Improve CLI option descriptions

This commit is contained in:
Marcin Kulik
2025-06-02 21:59:10 +02:00
parent 624379680a
commit 1b929911ad
6 changed files with 26 additions and 30 deletions

View File

@@ -29,7 +29,7 @@ pub enum Commands {
/// Stream a terminal session
Stream(Stream),
/// Record and/or stream a terminal session
/// Record and stream a terminal session
Session(Session),
/// Concatenate multiple recordings
@@ -48,7 +48,7 @@ pub enum Commands {
#[derive(Debug, Args)]
pub struct Record {
/// Output file path
pub output_path: String,
pub file: String,
/// Output file format [default: asciicast-v3]
#[arg(short = 'f', long, value_enum, value_name = "FORMAT")]
@@ -58,7 +58,7 @@ pub struct Record {
#[arg(short, long)]
pub command: Option<String>,
/// Enable input (keys) recording
/// Enable input (keyboard) recording
#[arg(long, short = 'I', alias = "stdin")]
pub rec_input: bool,
@@ -106,8 +106,8 @@ pub struct Record {
#[derive(Debug, Args)]
pub struct Play {
#[arg(value_name = "FILENAME_OR_URL")]
pub filename: String,
/// A path or an HTTP(S) URL of a recording file
pub file: String,
/// Limit idle time to a given number of seconds
#[arg(short, long, value_name = "SECS")]
@@ -145,7 +145,7 @@ pub struct Stream {
#[arg(short, long)]
pub command: Option<String>,
/// Enable input (keys) recording
/// Enable input (keyboard) recording
#[arg(long, short = 'I')]
pub rec_input: bool,
@@ -180,7 +180,7 @@ pub struct Stream {
#[derive(Debug, Args)]
pub struct Session {
/// Save the session in a file
/// Save the session to a file
#[arg(short, long, value_name = "PATH")]
pub output_file: Option<String>,
@@ -200,7 +200,7 @@ pub struct Session {
#[arg(short, long)]
pub command: Option<String>,
/// Enable input (keys) recording
/// Enable input (keyboard) recording
#[arg(long, short = 'I')]
pub rec_input: bool,
@@ -248,17 +248,16 @@ pub struct Session {
#[derive(Debug, Args)]
pub struct Cat {
#[arg(required = true, num_args = 2..)]
pub filename: Vec<String>,
pub file: Vec<String>,
}
#[derive(Debug, Args)]
pub struct Convert {
/// File to convert from, in asciicast format (use - for stdin)
#[arg(value_name = "INPUT_FILENAME_OR_URL")]
pub input_filename: String,
/// Input asciicast file path, an HTTP(S) URL, or - (for stdin)
pub input: String,
/// File to convert to (use - for stdout)
pub output_filename: String,
/// Output file path, or - (for stdout)
pub output: String,
/// Output file format [default: asciicast-v3]
#[arg(short = 'f', long, value_enum, value_name = "FORMAT")]
@@ -271,8 +270,8 @@ pub struct Convert {
#[derive(Debug, Args)]
pub struct Upload {
/// Filename/path of asciicast to upload
pub filename: String,
/// Path to an asciicast file to upload
pub file: String,
/// asciinema server URL
#[arg(long, value_name = "URL")]

View File

@@ -49,10 +49,7 @@ impl cli::Cat {
}
fn open_input_files(&self) -> Result<Vec<Asciicast>> {
self.filename
.iter()
.map(asciicast::open_from_path)
.collect()
self.file.iter().map(asciicast::open_from_path).collect()
}
fn get_encoder(&self, version: Version) -> Result<Box<dyn Encoder>> {

View File

@@ -23,7 +23,7 @@ impl cli::Convert {
fn get_encoder(&self) -> Box<dyn encoder::Encoder> {
let format = self.output_format.unwrap_or_else(|| {
if self.output_filename.to_lowercase().ends_with(".txt") {
if self.output.to_lowercase().ends_with(".txt") {
Format::Txt
} else {
Format::AsciicastV3
@@ -39,18 +39,18 @@ impl cli::Convert {
}
fn get_input_path(&self) -> Result<Box<dyn AsRef<Path>>> {
if self.input_filename == "-" {
if self.input == "-" {
Ok(Box::new(Path::new("/dev/stdin")))
} else {
util::get_local_path(&self.input_filename)
util::get_local_path(&self.input)
}
}
fn get_output_path(&self) -> String {
if self.output_filename == "-" {
if self.output == "-" {
"/dev/stdout".to_owned()
} else {
self.output_filename.clone()
self.output.clone()
}
}

View File

@@ -14,9 +14,9 @@ impl cli::Play {
let speed = self.speed.or(config.playback.speed).unwrap_or(1.0);
let idle_time_limit = self.idle_time_limit.or(config.playback.idle_time_limit);
status::info!("Replaying session from {}", self.filename);
status::info!("Replaying session from {}", self.file);
let path = util::get_local_path(&self.filename)?;
let path = util::get_local_path(&self.file)?;
let keys = get_key_bindings(&config.playback)?;
let ended = loop {

View File

@@ -8,8 +8,8 @@ use crate::config::Config;
impl cli::Upload {
pub fn run(self) -> Result<()> {
let config = Config::new(self.server_url.clone())?;
let _ = asciicast::open_from_path(&self.filename)?;
let response = api::upload_asciicast(&self.filename, &config)?;
let _ = asciicast::open_from_path(&self.file)?;
let response = api::upload_asciicast(&self.file, &config)?;
println!("{}", response.message.unwrap_or(response.url));
Ok(())

View File

@@ -40,7 +40,7 @@ fn main() -> ExitCode {
match cli.command {
Commands::Rec(cmd) => {
let cmd = Session {
output_file: Some(cmd.output_path),
output_file: Some(cmd.file),
rec_input: cmd.rec_input,
append: cmd.append,
output_format: cmd.output_format,