implement get command

master
nathaniel smith 2017-09-24 23:08:58 -07:00
parent 8d74dc91bb
commit 75d8495be8
1 changed files with 13 additions and 2 deletions

View File

@ -1,6 +1,7 @@
import os import os
import re import re
from os.path import expanduser from os.path import expanduser
import subprocess
import click import click
from click import ClickException, Abort from click import ClickException, Abort
@ -159,9 +160,19 @@ def publish(config, local_repo_path):
raise ClickException('Failed publishing wiki. Error: {}'.format(error)) raise ClickException('Failed publishing wiki. Error: {}'.format(error))
@main.command() @main.command()
@click.option('--preview', help='show pages from your local wiki', is_flag=True)
@click.option('--preview-path', default=PREVIEW_PATH,
help='Local path to wiki for previewing.', type=Path(file_okay=False))
@click.argument('path')
@pass_config @pass_config
def get(config): def get(config, preview, preview_path, path):
raise NotImplementedError() read_path = config.publish_path
if preview:
read_path = preview_path
path = os.path.join(read_path, path) + '.html'
subprocess.run(['sensible-browser', path])
@main.command() @main.command()
@click.option('--local-repo-path', default=LOCAL_REPOSITORY_PATH, @click.option('--local-repo-path', default=LOCAL_REPOSITORY_PATH,