diff options
Diffstat (limited to 'src/cmd/play.rs')
-rw-r--r-- | src/cmd/play.rs | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/src/cmd/play.rs b/src/cmd/play.rs index 22bd220..7eae765 100644 --- a/src/cmd/play.rs +++ b/src/cmd/play.rs @@ -1,10 +1,9 @@ use crate::prelude::*; use std::io::Write as _; -#[derive(serde::Deserialize, Debug)] +#[derive(serde::Deserialize, Debug, Default)] pub struct Config { - #[serde(default = "crate::config::default_ttyrec_filename")] - filename: String, + ttyrec: crate::config::Ttyrec, } impl crate::config::Config for Config { @@ -12,14 +11,11 @@ impl crate::config::Config for Config { &mut self, matches: &clap::ArgMatches<'a>, ) -> Result<()> { - if matches.is_present("filename") { - self.filename = matches.value_of("filename").unwrap().to_string(); - } - Ok(()) + self.ttyrec.merge_args(matches) } fn run(&self) -> Result<()> { - let fut = PlaySession::new(&self.filename); + let fut = PlaySession::new(&self.ttyrec.filename); tokio::run(fut.map_err(|e| { eprintln!("{}", e); })); @@ -27,14 +23,6 @@ impl crate::config::Config for Config { } } -impl Default for Config { - fn default() -> Self { - Self { - filename: crate::config::default_ttyrec_filename(), - } - } -} - pub fn cmd<'a, 'b>(app: clap::App<'a, 'b>) -> clap::App<'a, 'b> { app.about("Play recorded terminal sessions").arg( clap::Arg::with_name("filename") |