1 /// This module provides a DUB template for `dub init -t fluid`
2 module fluid.dub_template;
3
4 import std.file;
5 import std.string;
6 import std.process;
7
8 import std.stdio : writefln, stderr;
9
10
11 version (Fluid_InitExec):
12
13
14 void main() {
15
16 const mainFile = q{
17
18 import fluid;
19 import raylib;
20
21 void main() {
22
23 // Prepare the window
24 SetConfigFlags(ConfigFlags.FLAG_WINDOW_RESIZABLE);
25 SetTraceLogLevel(TraceLogLevel.LOG_WARNING);
26 InitWindow(800, 600, "Hello, Fluid!");
27 SetTargetFPS(60);
28 scope (exit) CloseWindow();
29
30 // Create UI
31 auto ui = label("Hello, World!");
32
33 // Event loop
34 while (!WindowShouldClose) {
35
36 BeginDrawing();
37 scope (exit) EndDrawing();
38
39 ClearBackground(color("fff"));
40
41 ui.draw();
42
43 }
44
45 }
46
47 };
48
49 const mainOutdent = mainFile
50 .splitLines
51 .outdent // Remove indent
52 .join("\n")
53 .strip; // Strip leading & trailing whitespace
54
55 if ("source".exists) {
56
57 stderr.writefln!"fluid: Directory 'source/' already exists, aborting.";
58 return;
59
60 }
61
62 // Prepare the source
63 mkdir("source");
64 write("source/main.d", mainOutdent);
65 append(".gitignore", "*.so\n");
66 append(".gitignore", "*.so.*\n");
67
68 // Install raylib
69 spawnShell("dub add raylib-d").wait;
70 spawnShell("dub run raylib-d:install -y -n").wait;
71
72 }