aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorPacien2013-06-28 15:31:04 +0200
committerPacien2013-06-28 15:31:04 +0200
commit6f2476510a5b31ada07a42c19065b47bbe784b7a (patch)
tree79e84f2bf2b8db8d964ad1c3383a6ad2161fa640 /main.go
parentcaeb79871d045ffeb2fba69c43b32b915a0a31c0 (diff)
downloadfoldaweb-6f2476510a5b31ada07a42c19065b47bbe784b7a.tar.gz
First version
Diffstat (limited to 'main.go')
-rw-r--r--main.go60
1 files changed, 60 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..49b27fa
--- /dev/null
+++ b/main.go
@@ -0,0 +1,60 @@
1/*
2
3 This file is part of CompileTree (https://github.com/Pacien/CompileTree)
4
5 CompileTree is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Affero General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 CompileTree is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with CompileTree. If not, see <http://www.gnu.org/licenses/>.
17
18*/
19
20package main
21
22import (
23 "flag"
24 "fmt"
25)
26
27var settings struct {
28 mode *string // compiled, interactive or dynamic
29 sourceDir *string
30 outputDir *string // for compiled site
31 port *string // for the integrated web server (dynamic mode only)
32}
33
34func init() {
35 // read settings
36 settings.mode = flag.String("mode", "compiled", "compiled|interactive|dynamic")
37 settings.sourceDir = flag.String("source", ".", "Path to sources directory.")
38 settings.outputDir = flag.String("output", "./out", "[compiled mode] Path to output directory.")
39 settings.port = flag.String("port", "8080", "[dynamic mode] Port to listen.")
40 flag.Parse()
41}
42
43func main() {
44 fmt.Println("CompileTree")
45 fmt.Println("Mode: " + *settings.mode)
46 fmt.Println("Source: " + *settings.sourceDir)
47 fmt.Println("Output: " + *settings.outputDir)
48 fmt.Println("====================")
49
50 switch *settings.mode {
51 case "compiled":
52 compiled(*settings.sourceDir, *settings.outputDir)
53 case "interactive":
54 interactive(*settings.sourceDir, *settings.outputDir)
55 case "dynamic":
56 dynamic(*settings.port)
57 default:
58 panic("Invalid mode.")
59 }
60}