Commit a1a94294 authored by Axel Dürkop's avatar Axel Dürkop
Browse files

Add clear function

parent e48e2063
......@@ -114,3 +114,6 @@ _book
*.epub
*.mobi
*.pdf
ABOUT.markdown
SUMMARY.markdown
#!/usr/bin/env python3
import os
import glob
# Reference: http://click.pocoo.org/5/
import click
# Reference: https://randomwords.readthedocs.io/en/latest/how_to_use.html
from random_words import LoremIpsum, RandomWords
@click.command()
@click.option('--pagecount', default=5, help='Number of pages.')
def generate_fakebook(pagecount):
@click.group()
def cli():
click.echo("+++ Generating GitBook...")
@cli.command()
@click.option('--pagecount', default=5, help='Number of pages.')
def fake(pagecount):
"""Generates a faked GitBook."""
page_titles = generate_list_of_pages(pagecount)
generate_ABOUT()
generate_SUMMARY(page_titles)
......@@ -62,5 +69,18 @@ def generate_SUMMARY(page_titles):
s.write(list_of_files)
s.close()
def abort_if_false(ctx, param, value):
if not value:
ctx.abort()
@cli.command()
@click.option('--yes', is_flag=True, callback=abort_if_false,
expose_value=False,
prompt='Are you sure you want to delete everything?')
def clear():
"""Deletes everything generated."""
for f in glob.glob('*.md'):
os.remove(f)
click.echo('Deleted the GitBook!')
if __name__ == "__main__":
generate_fakebook()
cli()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment