1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-08 18:14:21 +03:00
inform7/inrtps/Chapter 1/Main.w

57 lines
1.4 KiB
OpenEdge ABL
Raw Normal View History

2019-02-05 02:44:07 +02:00
[Main::] Main.
The top level, which decides what is to be done and then carries
this plan out.
@h Main routine.
@d PROGRAM_NAME "inrtps"
2019-02-27 21:29:15 +02:00
@d DEFAULT_FONT_TEXT
2019-02-05 02:44:07 +02:00
=
pathname *from_folder = NULL;
pathname *to_folder = NULL;
2019-02-27 21:29:15 +02:00
int font_setting = TRUE;
2019-02-05 02:44:07 +02:00
int main(int argc, char **argv) {
Foundation::start(argc, argv);
2019-02-27 21:29:15 +02:00
@<Read the command line@>;
if (from_folder) {
if (to_folder == NULL)
Errors::fatal("usage: inrtps from-folder to-folder [options]");
text_stream *f = NULL;
if (font_setting)
f = I"face='lucida grande,geneva,arial,tahoma,verdana,helvetica,helv'";
Translator::go(from_folder, to_folder, f);
}
Foundation::end();
return 0;
}
@ We use Foundation to read the command line:
@e FONT_CLSW
2019-02-05 02:44:07 +02:00
2019-02-27 21:29:15 +02:00
@<Read the command line@> =
2019-02-05 02:44:07 +02:00
CommandLine::declare_heading(
L"[[Purpose]]\n\n"
L"usage: inrtps from-folder to-folder [options]\n");
CommandLine::declare_boolean_switch(FONT_CLSW, L"font", 1,
2020-02-27 02:35:17 +02:00
L"explicitly set sans-serif fonts by name", TRUE);
2019-02-05 02:44:07 +02:00
2019-02-27 21:29:15 +02:00
CommandLine::read(argc, argv, NULL, &Main::option, &Main::bareword);
2019-02-05 02:44:07 +02:00
2019-02-27 21:29:15 +02:00
@ =
void Main::option(int id, int val, text_stream *arg, void *state) {
2019-02-05 02:44:07 +02:00
switch (id) {
2019-02-27 21:29:15 +02:00
case FONT_CLSW: font_setting = val; break;
2019-02-05 02:44:07 +02:00
}
}
2019-02-27 21:29:15 +02:00
void Main::bareword(int id, text_stream *arg, void *state) {
if (from_folder == NULL) from_folder = Pathnames::from_text(arg);
else if (to_folder == NULL) to_folder = Pathnames::from_text(arg);
else Errors::fatal("too many arguments given at command line");
2019-02-05 02:44:07 +02:00
}