aboutsummaryrefslogtreecommitdiff
path: root/cli/src/lib.rs
diff options
context:
space:
mode:
authorTill Höppner2016-02-25 18:08:08 +0100
committerTill Höppner2016-02-25 18:08:08 +0100
commit79c26253bbd7d78156b85fc3014c16786edc15af (patch)
tree9493c1683fded2efd786e2278da5ac38fc3067b0 /cli/src/lib.rs
parentdf63760e0e345e1ec390c647060a157bf627b67f (diff)
downloadilc-79c26253bbd7d78156b85fc3014c16786edc15af.tar.gz
ilc-79c26253bbd7d78156b85fc3014c16786edc15af.tar.xz
ilc-79c26253bbd7d78156b85fc3014c16786edc15af.zip
Merge alias to ease usage of sort+dedup
Diffstat (limited to 'cli/src/lib.rs')
-rw-r--r--cli/src/lib.rs20
1 files changed, 20 insertions, 0 deletions
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"),
};