#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import

import click

from zhihudaily.crawler import Crawler


@click.group()
def cli():
    """Simple script to fetch the zhihudaily news.

    \b
    - init database(deault will fetch 10 days' news)
        $ python fetch_date.py init
    - update database(fetch today's latest news and check data integrity)
        $ python fetch_date.py update
    - check data integrity, make sure we won't miss a day
        $ python fetch_date.py check <number>

    get more detailed info for each subcommand via <subcommand --help>
    """
    pass


@cli.command()
@click.option('--num', '-n')
def init(num=10):
    """init database."""
    crawler.init_database(num)


@cli.command()
def update():
    """Fetch today's latest news and save to database."""
    crawler.daily_update()


@cli.command()
@click.argument('date_range')
def check(date_range):
    """check data integrity."""
    crawler.check_integrity(date_range)


if __name__ == '__main__':
    crawler = Crawler()
    cli()

@@ -478,16 +478,39 @@
 ss a day
+(default check 10 days)
 %0A       
@@ -542,17 +542,8 @@
 heck
- %3Cnumber%3E
 %0A%0A  
@@ -672,16 +672,65 @@
 m', '-n'
+, default=10)%0A@click.option('--all', is_flag=True
 )%0Adef in
@@ -735,19 +735,21 @@
 init(num
-=10
+, all
 ):%0A    %22
@@ -756,35 +756,198 @@
 %22%22init database.
-%22%22%22
+%0A%0A    :param num: int, the number of daily news to fetch.%0A    :param all: boolean, fetch all the news or not.%0A    %22%22%22%0A    if all:%0A        crawler.init_database('all')
 %0A    crawler.ini
@@ -1106,29 +1106,79 @@
 ick.
-argument('date_range'
+option('--range', '-r', default=10)%0A@click.option('--all', is_flag=True
 )%0Ade
@@ -1185,26 +1185,26 @@
 f check(
-date_
 range
+, all
 ):%0A    %22
@@ -1230,45 +1230,209 @@
 ity.
-%22%22%22%0A    crawler.check_integrity(date_
+%0A%0A    :param range: int, the range of days to check%0A    :param all: boolean, check all the data integrity or not.%0A    %22%22%22%0A    if all:%0A        crawler.check_integrity('all')%0A    crawler.check_integrity(
 rang

Fix up the fetch_date.py