|
1 #!/usr/bin/env lua |
|
2 |
|
3 require "jorvick.util" |
|
4 |
|
5 local commands = {}; |
|
6 |
|
7 function commands.build() |
|
8 require "jorvick.build"; |
|
9 end |
|
10 |
|
11 function commands.create(...) |
|
12 local title = table.concat({...}, " "); |
|
13 if #title == 0 then |
|
14 title = os.date("New Post %Y-%m-%d"); |
|
15 end |
|
16 |
|
17 local filename = make_short_title(title); |
|
18 print(posts_dir..filename) |
|
19 local f = io.open(posts_dir..filename..".markdown", "r"); |
|
20 if f then print("File already exists or is unreable"); return; end |
|
21 f = io.open(posts_dir..filename..".markdown", "w+"); |
|
22 if not f then |
|
23 print("File not writeable"); |
|
24 end |
|
25 |
|
26 -- YAML |
|
27 --f:write(" |
|
28 end |
|
29 |
|
30 function commands.help() |
|
31 print "Jorvick - Blog Generator" |
|
32 print "" |
|
33 print "Commands:" |
|
34 print " create - Create a new blank post with a title" |
|
35 print " publish - Mark a post as published and stamp it with a date" |
|
36 print " build - Generate the HTML files and feed for all posts" |
|
37 print "" |
|
38 end |
|
39 |
|
40 local command = arg[1] or "help"; |
|
41 table.remove(arg, 1); |
|
42 (commands[command] or commands.help)(unpack(arg)); |