From 79c26253bbd7d78156b85fc3014c16786edc15af Mon Sep 17 00:00:00 2001 From: Till Höppner Date: Thu, 25 Feb 2016 18:08:08 +0100 Subject: Merge alias to ease usage of sort+dedup --- cli/src/lib.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'cli/src/lib.rs') diff --git a/cli/src/lib.rs b/cli/src/lib.rs index 0f91b89..40bc2e7 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -127,6 +127,9 @@ pub fn main() { .subcommand(SubCommand::with_name("sort").about("Sorts a log by time")) .subcommand(SubCommand::with_name("dedup") .about("Removes duplicate log entries in close proximity")) + .subcommand(SubCommand::with_name("merge") + .about("Merges the input logs. This has to keep everything \ + in memory")) .get_matches(); let res = match args.subcommand() { @@ -177,6 +180,23 @@ pub fn main() { &mut *e.output(), &*e.encoder()) } + ("merge", Some(args)) => { + // TODO: avoid (de-)serialization to weechat + let e = Environment(&args); + let (ctx, i, d, o, e) = (&e.context(), + &mut e.input(), + &mut *e.decoder(), + &mut *e.output(), + &*e.encoder()); + let mut buffer = Vec::new(); + match sort::sort(ctx, i, d, &mut buffer, &Weechat) { + Err(e) => error(Box::new(e)), + _ => (), + } + let mut read = io::Cursor::new(&buffer); + dedup::dedup(ctx, &mut read, &mut Weechat, o, e) + + } (sc, _) if !sc.is_empty() => panic!("Unimplemented subcommand `{}`, this is a bug", sc), _ => die("No command specified"), }; -- cgit v1.2.3