# Path: rvo/validate.py
# def validate_date(ctx, param, value):
#     try:
#         value = parse(value)
#         return value
#     except (AttributeError, TypeError) as e:
#         return value
#     except ValueError:
#         raise click.BadParameter('Date format \"%s\" not valid' % value)


import re
import click
import datetime
import rvo.db as db
import rvo.utils as utils
import rvo.views as views
from rvo.validate import validate_date

@click.command(short_help="List documents from store",
               help="""
               Lists documents from the documentstore

               By default, the 10 latest documents will be shown.
               As documents grow, it gets difficult to find those.

               Filters can be applied on list command.
               See options below on how to filter the output.

               """)
@click.option('-t', '--tag', type=str, multiple=True,
              help='Results have to contain this tag')
@click.option('-c', '--category', type=str, multiple=True,
              help='Results need to be in this category')
@click.option('-s', '--title', type=str, multiple=True,
              help='Results need to contain this string in title')
@click.option('-x', '--content', type=str, multiple=True,
              help='Results need to contain this string in content')
@click.option('-l', '--limit', type=int, default=10,
              help='Limit the number of results')
@click.option('datefrom', '-f', '--from', default=datetime.datetime.utcfromtimestamp(0),
              callback=validate_date,
              help='Results by date starting from')
@click.option('dateto', '-d', '--to', default=datetime.datetime.now(),

# Path: rvo/validate.py
# def validate_date(ctx, param, value):
#     try:
#         value = parse(value)
#         return value
#     except (AttributeError, TypeError) as e:
#         return value
#     except ValueError:
#         raise click.BadParameter('Date format \"%s\" not valid' % value)


# Path: rvo/commands/list.py
import re
import click
import datetime
import rvo.db as db
import rvo.utils as utils
import rvo.views as views
from rvo.validate import validate_date


@click.command(short_help="List documents from store",
               help="""
               Lists documents from the documentstore

               By default, the 10 latest documents will be shown.
               As documents grow, it gets difficult to find those.

               Filters can be applied on list command.
               See options below on how to filter the output.

               """)
@click.option('-t', '--tag', type=str, multiple=True,
              help='Results have to contain this tag')
@click.option('-c', '--category', type=str, multiple=True,
              help='Results need to be in this category')
@click.option('-s', '--title', type=str, multiple=True,
              help='Results need to contain this string in title')
@click.option('-x', '--content', type=str, multiple=True,
              help='Results need to contain this string in content')
@click.option('-l', '--limit', type=int, default=10,
              help='Limit the number of results')
@click.option('datefrom', '-f', '--from', default=datetime.datetime.utcfromtimestamp(0),
              callback=validate_date,
              help='Results by date starting from')
@click.option('dateto', '-d', '--to', default=datetime.datetime.now(),

              callback=validate_date,