-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.py
executable file
·64 lines (56 loc) · 2.11 KB
/
flake.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
from flake.flake import *
import datetime
import os
import errno
if __name__ == '__main__':
if len(sys.argv) > 1 and sys.argv[1] == "--help" or sys.argv[1] == "-h":
# Print helper function docs
print('''
flake v0.1\n
Padam Sethia <padamsethia5@gmail.com>\n
Static Site generator written with flask and python.\n
USAGE:
\t ./flake.py [FLAGS] [OPTIONS]\n\n
FLAGS:
\t -h, --help\t Displays the help section\n
\t -b, build\t Freezes to static files at root\n
\t -n, new\t New post/page\n
\t -u, update\t Updates flake from root repository\n
\t -r, run\t Runs on local server\n
OPTIONS:
\t post\t Used with new to create a new post\n
\t port\t Set desired port number for run\n''')
# creates local build
if len(sys.argv) > 1 and sys.argv[1] == "build":
freezer.freeze()
if len(sys.argv) > 1 and sys.argv[1] == "new":
now = datetime.datetime.now()
now = now.strftime("%-d %b %Y")
title = str(raw_input("Enter title for the post : "))
filename = "./flake/pages/" + title + ".md"
if not os.path.exists(os.path.dirname(filename)):
try:
os.makedirs(os.path.dirname(filename))
except OSError as exc: # Guard against race condition
if exc.errno != errno.EEXIST:
raise
with open(filename, "w") as f:
f.write("title: " + title + "\ndate: " + now + "\n\nWrite here.")
# Update flake from base repo
#if len(sys.argv) > 1 and sys.argv[1] == "update":
# Needs fixing
# git_dir = "./"
# g = git.cmd.Git(git_dir)
# g.pull()
if len(sys.argv) > 1 and sys.argv[1] == "run":
'''
Runs a local server with website
'''
#port = int(sys.argv[2])
flake.run(debug=False , port = 5000)
if len(sys.argv) > 1 and sys.argv[1] == "run" and sys.argv[2] == "debug":
'''
Runs a local server with website with debug
'''
flake.run(debug=True)