diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 60 |
1 files changed, 60 insertions, 0 deletions
@@ -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 | |||
20 | package main | ||
21 | |||
22 | import ( | ||
23 | "flag" | ||
24 | "fmt" | ||
25 | ) | ||
26 | |||
27 | var 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 | |||
34 | func 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 | |||
43 | func 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 | } | ||