Initial commit
This commit is contained in:
Executable
+56
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
# The CMS portion of simple_blog a self-hosted blogging platform.
|
||||
# Version 0.1
|
||||
# 03/12/2022
|
||||
|
||||
# imports
|
||||
import configparser
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
import find_ini
|
||||
import publish_blog
|
||||
import sb_config
|
||||
|
||||
# Start of 'main'
|
||||
script_name = "simple_blog"
|
||||
script_version = "0.1"
|
||||
help_epilog = ""
|
||||
find_ini.find_ini()
|
||||
cmd_option_set = argparse.ArgumentParser(description='Publish your thoughts with simple_blog.', epilog=help_epilog)
|
||||
cmd_option_set.add_argument('--conf', '-C', dest='run_conf', action='store_true', help='Run the self configuration '
|
||||
'routine.')
|
||||
cmd_option_set.add_argument('--report-conf', '-R', dest='report_config', action='store_true', help='Reports the '
|
||||
'current '
|
||||
'configuration.')
|
||||
cmd_option_set.add_argument('--publish', '-p', dest='publish', action='store_true', help='Publishes an article. If no '
|
||||
'article is explicitly '
|
||||
'provided '
|
||||
' (-a) it will parse the '
|
||||
'current directory for '
|
||||
'Markdown '
|
||||
'files.')
|
||||
cmd_option_set.add_argument('--article', '-a', dest='article_path', type=str,
|
||||
help='Path to the Markdown file to be published.')
|
||||
cmd_option_set.add_argument('--version', '-v', dest='print_version', action='store_true',
|
||||
help='Print the current version number.')
|
||||
cmd_options = cmd_option_set.parse_args()
|
||||
|
||||
option_file = find_ini.find_ini()
|
||||
simple_blog_conf = configparser.ConfigParser()
|
||||
simple_blog_conf.read(option_file)
|
||||
# Testing for command line flags.
|
||||
if cmd_options.run_conf:
|
||||
sb_config.write_conf("Configuring", True)
|
||||
sys.exit(0)
|
||||
elif cmd_options.report_config:
|
||||
sb_config.report_conf(simple_blog_conf)
|
||||
sys.exit(0)
|
||||
elif cmd_options.publish:
|
||||
if cmd_options.article_path is not None:
|
||||
publish_blog.publish_path(cmd_options.article_path )
|
||||
else:
|
||||
publish_blog.publish_parse()
|
||||
elif cmd_options.print_version:
|
||||
print("Script version: " + script_version)
|
||||
sys.exit(0)
|
||||
Reference in New Issue
Block a user