import click
from artefacts import Image
import pipelines
from processresult import recorder


@click.group()
def cli():
    pass


@cli.command()
@click.argument('t1', type=click.Path(exists=True, dir_okay=False))
@click.argument('t2', type=click.Path(exists=True, dir_okay=False))
@click.argument('t2_lesions', type=click.Path(exists=True, dir_okay=False))
def fill_and_extract_brain(t1, t2, t2_lesions):
    recorder.run(
        'fill_and_extract_brain',
        pipelines.fill_and_extract_brain,
        Image(t1),
        Image(t2)
    )


@cli.command()
@click.argument('t1', type=click.Path(exists=True, dir_okay=False))
@click.argument('t2', type=click.Path(exists=True, dir_okay=False))
@click.argument('t2_lesions', type=click.Path(exists=True, dir_okay=False))
@click.argument('mton_short', type=click.Path(exists=True, dir_okay=False))
@click.argument('mtoff_short', type=click.Path(exists=True, dir_okay=False))
@click.argument('mton_long', type=click.Path(exists=True, dir_okay=False))
@click.argument('mtoff_long', type=click.Path(exists=True, dir_okay=False))
def mtr(t1, t2, t2_lesions, mton_short, mtoff_short, mton_long, mtoff_long):
    recorder.run(
        'mtr',
        pipelines.mtr,
        Image(t1),
        Image(t2),
        Image(t2_lesions),
        Image(mton_short),
        Image(mtoff_short),
        Image(mton_long),
        Image(mtoff_long)
    )


@cli.command()
@click.argument('input_file', type=click.Path(exists=True, dir_okay=False))
def test(input_file):
    recorder.run(
        'test',
        pipelines.test,
        Image(input_file)
    )


if __name__ == '__main__':
    cli()

@@ -107,27 +107,130 @@
 p()%0A
-def cli():%0A    pass
+@click.option('--debug/--no-debug', default=False)%0A@click.pass_context%0Adef cli(ctx, debug):%0A    ctx.obj = %7B'DEBUG': debug%7D
 %0A%0A%0A@
@@ -451,24 +451,44 @@
 kay=False))%0A
+@click.pass_context%0A
 def fill_and
@@ -502,16 +502,21 @@
 t_brain(
+ctx, 
 t1, t2, 
@@ -658,16 +658,48 @@
 mage(t2)
+,%0A        debug=ctx.obj%5B'DEBUG'%5D
 %0A    )%0A%0A
@@ -1234,16 +1234,36 @@
 e))%0A
+@click.pass_context%0A
 def mtr(
 t1, 
@@ -1258,16 +1258,21 @@
 def mtr(
+ctx, 
 t1, t2, 
@@ -1559,16 +1559,48 @@
 ff_long)
+,%0A        debug=ctx.obj%5B'DEBUG'%5D
 %0A    )%0A%0A
@@ -1691,16 +1691,36 @@
 False))%0A
+@click.pass_context%0A
 def test
@@ -1720,16 +1720,21 @@
 ef test(
+ctx, 
 input_fi
@@ -1796,16 +1796,16 @@
 s.test,%0A
-
         
@@ -1821,16 +1821,48 @@
 ut_file)
+,%0A        debug=ctx.obj%5B'DEBUG'%5D
 %0A    )%0A%0A

Add debug option to cli