aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2019-05-26 18:16:49 +0200
committerneodarz <neodarz@neodarz.net>2019-05-26 18:16:49 +0200
commit04688cd6ff58d09c950ae9791a7d2a6bc066704a (patch)
tree049521eea47429e956ff840f2f31ab4c3c6cfe92
parent8ae8db0798f9572b07f05b8a0120470a5417acab (diff)
downloadmy_new_personal_website-04688cd6ff58d09c950ae9791a7d2a6bc066704a.tar.xz
my_new_personal_website-04688cd6ff58d09c950ae9791a7d2a6bc066704a.zip
Move edit_existing_post to external file
-rw-r--r--cli/cli.py12
-rwxr-xr-xpyblog12
2 files changed, 13 insertions, 11 deletions
diff --git a/cli/cli.py b/cli/cli.py
index ed2680f4..d5caf15f 100644
--- a/cli/cli.py
+++ b/cli/cli.py
@@ -13,6 +13,8 @@ import time
import signal
+import blessed
+
from config.config import *
from utils import utils
@@ -355,3 +357,13 @@ def preview(args):
sys.stderr.write("\nSIGINT received, cleaning up...\n")
server_process.join()
return 0
+
+
+def edit_existing_post(args):
+ selector = utils.PostSelector(blessed.Terminal(), utils.list_posts())
+ selection = selector.select()
+ if selection:
+ print(selection)
+ edit_post_with_editor(selection)
+ else:
+ return 1
diff --git a/pyblog b/pyblog
index 8813d4af..37a37bc3 100755
--- a/pyblog
+++ b/pyblog
@@ -53,16 +53,6 @@ from generators import generators
from cli import cli
-def edit_existing_post(args):
- selector = utils.PostSelector(blessed.Terminal(), utils.list_posts())
- selection = selector.select()
- if selection:
- print(selection)
- cli.edit_post_with_editor(selection)
- else:
- return 1
-
-
def main():
"""CLI interface."""
description = "Simple blog generator in Python with Pandoc as backend."
@@ -119,7 +109,7 @@ def main():
parser_new_post = subparsers.add_parser(
"edit", aliases=["e", "ed"],
description="Bring up post selector to select post for editing.")
- parser_new_post.set_defaults(func=edit_existing_post)
+ parser_new_post.set_defaults(func=cli.edit_existing_post)
with utils.init_colorama():
args = parser.parse_args()