23 using namespace UCOMMON_NAMESPACE;
25 static shell::flagopt helpflag(
'h',
"--help", _TEXT(
"display this list"));
26 static shell::flagopt althelp(
'?', NULL, NULL);
27 static shell::stringopt lang(
'L',
"--lang", _TEXT(
"specify language"),
"language",
"C");
28 static shell::stringopt prefix(
'P',
"--prefix", _TEXT(
"specify alternate prefix path"),
"path", NULL);
29 static shell::stringopt suffix(
'S',
"--suffix", _TEXT(
"audio extension"),
".ext",
".au");
30 static shell::stringopt voice(
'V',
"--voice", _TEXT(
"specify voice library"),
"name",
"default");
31 static shell::stringopt phrasebook(
'B',
"--phrasebook", _TEXT(
"specify phrasebook directory"),
"path", NULL);
32 static Env::pathinfo_t ruleset;
33 static bool showpath =
false;
35 static void display(
char **args)
38 Phrasebook::rule_t rule;
44 const char **out = &
state.rule.list[0];
45 const char *arg = *(args++);
47 if(eq(arg,
"@number/", 8))
48 ruleset->number(arg + 8, &
state.rule);
49 else if(eq(arg,
"@number")) {
52 shell::errexit(4,
"*** phrasebook: @number: %s\n", _TEXT(
"argument missing"));
53 ruleset->number(arg, &
state.rule);
55 else if(eq(arg,
"@time/", 6))
56 ruleset->time(arg + 6, &
state.rule);
57 else if(eq(arg,
"@time")) {
60 shell::errexit(4,
"*** phrasebook: @time: %s\n", _TEXT(
"argument missing"));
61 ruleset->time(arg, &
state.rule);
63 else if(eq(arg,
"@date/", 6))
64 ruleset->date(arg + 6, &
state.rule);
65 else if(eq(arg,
"@date")) {
68 shell::errexit(4,
"*** phrasebook: @date: %s\n", _TEXT(
"argument missing"));
69 ruleset->date(arg, &
state.rule);
71 else if(eq(arg,
"@weekday/", 9))
72 ruleset->weekday(arg + 9, &
state.rule);
73 else if(eq(arg,
"@weekday")) {
76 shell::errexit(4,
"*** phrasebook: @fulldate: %s\n", _TEXT(
"argument missing"));
77 ruleset->weekday(arg, &
state.rule);
79 else if(eq(arg,
"@fulldate/", 10))
80 ruleset->fulldate(arg + 10, &
state.rule);
81 else if(eq(arg,
"@fulldate")) {
84 shell::errexit(4,
"*** phrasebook: @fulldate: %s\n", _TEXT(
"argument missing"));
85 ruleset->fulldate(arg, &
state.rule);
87 else if(eq(arg,
"@spell/", 7))
88 ruleset->spell(arg + 7, &
state.rule);
89 else if(eq(arg,
"@spell")) {
92 shell::errexit(4,
"*** phrasebook: @spell: %s\n", _TEXT(
"argument missing"));
93 ruleset->spell(arg, &
state.rule);
95 else if(eq(arg,
"@order/", 7))
96 ruleset->order(arg + 7, &
state.rule);
97 else if(eq(arg,
"@order")) {
100 shell::errexit(4,
"*** phrasebook: @order: %s\n", _TEXT(
"argument missing"));
101 ruleset->order(arg, &
state.rule);
105 ruleset->literal(arg, &
state.rule);
107 ruleset.voices = *voice;
110 printf(
"*** %s: failed", arg);
117 const char *file = Env::path(ruleset, *out, buffer,
sizeof(buffer),
true);
119 printf(
"*** %s: invalid\n", *out);
121 printf(
"%s\n", file);
125 printf(
"%s ", *(out++));
134 shell::bind(
"phrasebook");
135 shell args(argc, argv);
140 Env::set(
"prefix", *prefix);
143 Env::set(
"voices", *phrasebook);
146 Env::set(
"extension", *suffix);
148 if(is(helpflag) || is(althelp)) {
149 printf(
"%s\n", _TEXT(
"Usage: phrasebook [options] command arguments..."));
150 printf(
"%s\n\n", _TEXT(
"Phrasebook operations"));
151 printf(
"%s\n", _TEXT(
"Options:"));
153 printf(
"\n%s\n", _TEXT(
"Report bugs to dyfet@gnu.org"));
158 shell::errexit(1,
"*** phrasebook: %s\n",
159 _TEXT(
"no command specified"));
161 const char *cmd = args[0];
167 ruleset.book = Phrasebook::find(*lang);
169 ruleset.book = Phrasebook::find(NULL);
172 shell::errexit(3,
"*** phrasebook: %s: %s\n",
173 *lang, _TEXT(
"language not found"));
175 if(case_eq(cmd,
"display"))
177 else if(case_eq(cmd,
"paths")) {
182 shell::errexit(2,
"*** phrasebook: %s: %s\n",
183 cmd, _TEXT(
"unknown command"));
#define BAYONNE_NAMESPACE
GNU Bayonne library namespace.