From 2360b25d730b6692a99f3077d78ae68a241f5de3 Mon Sep 17 00:00:00 2001 From: nathaniel smith Date: Mon, 2 Oct 2017 22:37:59 -0700 Subject: [PATCH] get command can now get directory indices --- tildewiki/main.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tildewiki/main.py b/tildewiki/main.py index edb4665..996eb8f 100644 --- a/tildewiki/main.py +++ b/tildewiki/main.py @@ -170,10 +170,23 @@ def get(config, preview, preview_path, path): if preview: read_path = preview_path - path = os.path.join(read_path, path) + '.html' + path = os.path.join(read_path, path) + if os.path.exists(path)\ + and os.path.isdir(path)\ + and os.path.exists(os.path.join(path, 'index.html')): + path = os.path.join(path, 'index.html') + elif os.path.exists(path + '.html'): + path = path + '.html' + else: + raise ClickException("Couldn't find path {}".format(path)) subprocess.run(['sensible-browser', path]) +# TODO sync command that: +# - offers to wipe any local changes or commit them +# - pulls from origin +# - pushes to origin + @main.command() @click.option('--local-repo-path', default=LOCAL_REPOSITORY_PATH, help='Path to shared wiki git repository.', type=WikiRepo(**DEFAULT_PATH_KWARGS))