summaryrefslogtreecommitdiffstats
path: root/src/cli/main.vala
diff options
context:
space:
mode:
authorHolger Cremer <HolgerCremer@gmail.com>2018-08-27 19:38:11 +0200
committerHolger Cremer <HolgerCremer@gmail.com>2018-08-27 19:38:11 +0200
commit8f2ba2050ee78d0e4a47f1277c6bc4422d06170c (patch)
treec008d2878905e03df7a8bf8bd3330762cc2d8f43 /src/cli/main.vala
parentbb55e121576a5b5d225bfc68c5062f386cc32db9 (diff)
parent3fc3ea6c6df237dbdf48d14703118b747bf5d647 (diff)
downloadserial-barcode-scanner-8f2ba2050ee78d0e4a47f1277c6bc4422d06170c.tar.bz2
Merge branch 'master' into better_inventory
Conflicts: README data/templates/products/entry.html docker/Dockerfile docker/init.sh src/database/database.vala src/database/db-interface.vala src/pdf-stock/Makefile src/pdf-stock/pdf-stock-interface.vala src/pdf-stock/pdf-stock.vala src/web/Makefile src/web/main.vala templates/menu.html templates/products/index.html
Diffstat (limited to 'src/cli/main.vala')
-rw-r--r--src/cli/main.vala32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/cli/main.vala b/src/cli/main.vala
index a3208dd..aacb3ba 100644
--- a/src/cli/main.vala
+++ b/src/cli/main.vala
@@ -18,20 +18,23 @@ MainLoop ml;
string[] commands;
public static int main(string[] args) {
+ Intl.setlocale(LocaleCategory.ALL, "");
+ Intl.textdomain("shopsystem");
+
if (args.length == 1) {
- stdout.printf("Nothing to send.\nUsage: %s <commnds to send...>\nExample: %s \"USER 1\" \"LOGOUT\"\n", args[0], args[0]);
+ stdout.printf(_("Nothing to send.\nUsage: %s <commands to send...>\nExample: %s \"USER 1\" \"LOGOUT\"\n"), args[0], args[0]);
return 0;
}
commands = args[1:args.length];
-
+
cli = new CliImpl();
Bus.own_name(
BusType.SYSTEM,
"io.mainframe.shopsystem.Cli",
BusNameOwnerFlags.NONE,
- on_bus_aquired,
- on_name_aquired,
- () => stderr.printf("Could not aquire name\n"));
+ on_bus_acquired,
+ on_name_acquired,
+ () => stderr.printf(_("Could not acquire name\n")));
ml = new MainLoop();
@@ -40,9 +43,13 @@ public static int main(string[] args) {
return 0;
}
-void on_name_aquired() {
+void on_name_acquired() {
foreach (string cmd in commands) {
- cli.send(cmd);
+ try {
+ cli.send(cmd);
+ } catch (Error e) {
+ stderr.printf(_("Error sending command: %s"), e.message);
+ }
}
// wait a minimal amount of time, to ensure the event was sent
@@ -51,15 +58,14 @@ void on_name_aquired() {
ml.quit ();
return false;
});
- time.attach (ml.get_context ());
-
+ time.attach (ml.get_context ());
}
-void on_bus_aquired(DBusConnection con) {
+void on_bus_acquired(DBusConnection con) {
try {
- con.register_object("/io/mainframe/shopsystem/cli", cli);
+ con.register_object("/io/mainframe/shopsystem/cli", cli);
} catch(IOError e) {
- stderr.printf("Could not register service\n");
+ stderr.printf(_("Could not register service\n"));
}
-} \ No newline at end of file
+}