# coding=utf-8
# Filename: cmd.py
"""
KM3Pipe command line utility.

Usage:
    km3pipe test
    km3pipe tohdf5 [-s] -i FILE -o FILE
    km3pipe (-h | --help)
    km3pipe --version

Options:
    -h --help  Show this screen.
    -i FILE    Input file.
    -o FILE    Output file.
    -s         Write each event in a separate dataset.

"""
from __future__ import division, absolute_import, print_function

from km3pipe import version


def tohdf5(input_file, output_file, use_tables=True):
    """Convert ROOT file to HDF5 file"""
    from km3pipe import Pipeline  # noqa
    from km3pipe.pumps import AanetPump, HDF5Sink, HDF5TableSink  # noqa

    sink = HDF5TableSink if use_tables else HDF5Sink

    pipe = Pipeline()
    pipe.attach(AanetPump, filename=input_file)
    pipe.attach(sink, filename=output_file)
    pipe.drain()


def main():
    from docopt import docopt
    arguments = docopt(__doc__, version=version)

    if arguments['tohdf5']:
        tohdf5(arguments['-i'], arguments['-o'], arguments['-s'])

@@ -108,13 +108,8 @@
 hdf5
- %5B-s%5D
  -i 
@@ -121,16 +121,16 @@
 -o FILE%0A
+
     km3p
@@ -270,63 +270,8 @@
 ile.
-%0A    -s         Write each event in a separate dataset.
 %0A%0A%22%22
@@ -406,25 +406,8 @@
 file
-, use_tables=True
 ):%0A 
@@ -531,18 +531,8 @@
 ump,
- HDF5Sink,
  HDF
@@ -555,62 +555,8 @@
 qa%0A%0A
-    sink = HDF5TableSink if use_tables else HDF5Sink%0A%0A
     
@@ -637,17 +637,26 @@
 .attach(
-s
+HDF5TableS
 ink, fil
@@ -813,16 +813,16 @@
 hdf5'%5D:%0A
+
         
@@ -864,23 +864,6 @@
 -o'%5D
-, arguments%5B'-s'%5D
 )%0A

Make table sink standard