-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.d
More file actions
55 lines (44 loc) · 997 Bytes
/
app.d
File metadata and controls
55 lines (44 loc) · 997 Bytes
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
import std.stdio;
import std.getopt;
import std.file;
import sdlss;
struct Settings
{
struct Com
{
string dev = "/dev/ttyUSB0";
int baudrate = 19200;
string mode = "8N1";
}
Com com;
struct Data
{
string name;
int[] signal;
}
Data[] data = [Data("first", [1, 1, 2, 3, 5])];
}
int main(string[] args)
{
string sets_file = "settings.sdl";
bool gen_default;
getopt(args,
"settings-file", &sets_file,
"gen-default-settings", &gen_default
);
if (gen_default)
{
stderr.writefln("generate default settings to '%s'", sets_file);
writeStruct(Settings.init, sets_file);
return 0;
}
if (!sets_file.exists)
{
stderr.writefln("no settings file found '%s'", sets_file);
stderr.writefln("use:\n%s --gen-default-settings", args[0]);
return 1;
}
auto sets = readStruct!Settings(sets_file);
writeln(sets);
return 0;
}